Hi,
I have a problem with my QDockWidget, I want it to take all available width space. But it only takes the minimum space...
This is the source code that I do :
//testWidget.h
{
Q_OBJECT
public:
explicit testWidget
(QWidget *parent
= 0);
};
//testWidget.h
class testWidget : public QWidget
{
Q_OBJECT
public:
explicit testWidget(QWidget *parent = 0);
QLabel test;
QPushButton testButton;
};
To copy to clipboard, switch view to plain text mode
//testWidget.cpp
testWidget
::testWidget(QWidget *parent
) :{
setStyleSheet("background-color: yellow");
test.setText("test label");
test.setParent(this);
test.setVisible(true);
testButton.setText("TestButton");
testButton.setParent(this);
testButton.move(0, 20);
testButton.setVisible(true);
}
//testWidget.cpp
testWidget::testWidget(QWidget *parent) :
QWidget(parent)
{
setStyleSheet("background-color: yellow");
test.setText("test label");
test.setParent(this);
test.setVisible(true);
testButton.setText("TestButton");
testButton.setParent(this);
testButton.move(0, 20);
testButton.setVisible(true);
}
To copy to clipboard, switch view to plain text mode
//mainWindow.h
{
Q_OBJECT
public:
explicit mainWindow
(QWidget *parent
= 0);
testWidget *testW;
};
//mainWindow.h
class mainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit mainWindow(QWidget *parent = 0);
testWidget *testW;
};
To copy to clipboard, switch view to plain text mode
//mainWindow.cpp
mainWindow
::mainWindow(QWidget *parent
){
setFixedSize(1000, 900);
test->setFixedSize(500,900);
test->setStyleSheet("background-color: black;");
setCentralWidget(test);
testW = new testWidget;
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setWidget(testW);
addDockWidget(Qt::RightDockWidgetArea, dock);
}
//mainWindow.cpp
mainWindow::mainWindow(QWidget *parent)
: QMainWindow(parent)
{
setFixedSize(1000, 900);
QLabel *test = new QLabel;
test->setFixedSize(500,900);
test->setStyleSheet("background-color: black;");
setCentralWidget(test);
testW = new testWidget;
QDockWidget *dock = new QDockWidget("DOCKTEST", this);
dock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setWidget(testW);
addDockWidget(Qt::RightDockWidgetArea, dock);
}
To copy to clipboard, switch view to plain text mode
The result is:
1335632129-Capturedu2012-04-28185448.jpg
And I want that :
1335632129-Capturedu2012-04-28185455.jpg
I don't know how to do that, and if I add 2 widgets in the QDockWidget, how can I only define the height value ? (maybe 2/3 for the first one, and 1/3 for the second one)
So, if someone can help me, it will be very great !
Thanks in advance for your help,
Bookmarks