0

I currently working on an project in Qt. This project includes an DockWidget, called "ProjectExplorer". I display this with this technique: FPHMainWindow.h

#ifndef FPHMAINWINDOW_H
#define FPHMAINWINDOW_H

#include <QMainWindow>

class ProjectExplorer;

namespace Ui {
class FPHMainWindow;
}

class FPHMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit FPHMainWindow(QWidget *parent = 0);
    ~FPHMainWindow();

private slots:
    void on_actionNewProject_triggered();

    void on_actionImportProject_triggered();

    void on_actionNew_triggered();

    void on_NEWTB__cancel_clicked();

private:
    Ui::FPHMainWindow *ui;
    ProjectExplorer *mProjectExplorer;
};

#endif // FPHMAINWINDOW_H

And in FPHMainWindow.cpp:

FPHMainWindow::FPHMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::FPHMainWindow),
    mProjectExplorer(new ProjectExplorer(this))
{
    // Code...


    /* Adding DockWidgets to MainWindow */
    addDockWidget(Qt::LeftDockWidgetArea, mProjectExplorer);

}

But now If I start the program it looks like this:

https://i.stack.imgur.com/7vAag.png

But I want an size of Width: 388, Heigth: 477 ON START! How I can fix this "issue"?

Thanks, Charles

Charles44
  • 1
  • 1
  • the image you post is unclearly. Well I suppose you call to `ui->setupUi( this );` method in the constructor. On the other hand, if you want to setup widget size, you can call to `QWidget::resize( QSize )` or `QWidget::resize( int w, int h )` methods. – eferion Sep 02 '14 at 11:04
  • 1
    @eferion QWidget::resize(...) doesn't works for me, nothing changes. In the image I mean, in designer the DockWidget has the size I want and by run, the DockWidget hasn't the same size like in designer. – Charles44 Sep 02 '14 at 11:12
  • @Charles44, you can set the minimal size of the inner widget - the one that the dock widget contains. – vahancho Sep 02 '14 at 11:20
  • You can call `setFixedSize()` too, which sets min, max and the size policy to fixed. I'm having the same problem, but do not want to set the minimum size, I simply want to remember/restore the size of my `QDockWidgets`. Restoring state and geometry on my `QMainWindow` does not work either. My issue seems to be [this one](http://stackoverflow.com/questions/14215897/resize-a-qdockwidget). – jtooker Oct 08 '14 at 13:50

0 Answers0