My layout doesn't work
-
Hi everyone. I'm creating a layout for my app.
I want the two widget to be displayed on the left and the RenderWidget be on the right.
Here is my code but the RenderWidget is not displayed.@MainUI::MainUI()
{
m_ObjectListWidget = new QListWidget;
m_PhysicsConfModel = new QStandardItemModel(3, 2, this);
m_PhysicsConfWidget = new QTableView;
m_RenderWidget = new QWidget;
m_InfoWidget = new QWidget;
m_MainWidget = new QWidget;m_HBoxLayout = new QHBoxLayout; m_VBoxLayout = new QVBoxLayout; m_RenderWidget->setAttribute(Qt::WA_PaintOnScreen); m_PhysicsConfWidget->setModel(m_PhysicsConfModel); m_VBoxLayout->addWidget(m_PhysicsConfWidget); m_VBoxLayout->addWidget(m_ObjectListWidget); m_InfoWidget->setLayout(m_VBoxLayout); m_HBoxLayout->addWidget(m_InfoWidget); m_HBoxLayout->addWidget(m_RenderWidget); m_MainWidget->setLayout(m_HBoxLayout); resize(800, 600); setCentralWidget(m_MainWidget);
}@
!http://s30.postimg.org/j0wynmckx/image.png(no image)!
I tried commenting out the line m_InfoWidget->setLayout(m_VBoxLayout);
which made the InfoWidget be an empty Widget and it worked like this:!http://s18.postimg.org/qcyp06xi1/image.png(no image)!
But I can not add two widgets to the InfoWidget on the left and display it with a QVBoxLayout. Anyone can help me to fix this?
I'm using Qt 4.8.6 with CodeBlocks (MinGW) on an XP 32bit.
Thank you. -
Hi,
Does something like:
@
m_ObjectListWidget = new QListWidget;
m_PhysicsConfWidget = new QTableView;
m_RenderWidget = new QWidget;
m_MainWidget = new QWidget;m_VBoxLayout = new QVBoxLayout; m_VBoxLayout->addWidget(m_PhysicsConfWidget); m_VBoxLayout->addWidget(m_ObjectListWidget); m_HBoxLayout = new QHBoxLayout(m_MainWidget); m_HBoxLayout->addLayout(m_VBoxLayout); m_HBoxLayout->addWidget(m_RenderWidget); setCentralWidget(m_MainWidget);
@
work ?
-
Thank you but the RenderWidget is still not displayed
!http://s29.postimg.org/cfcapd21z/image.png(no image)! -
Even if I remove the renderer and add a empty widget the result is still the same as picture 1.
@MainUI::MainUI()
{
m_ObjectListWidget = new QListWidget;
m_PhysicsConfModel = new QStandardItemModel(3, 2, this);
m_PhysicsConfWidget = new QTableView;
m_RenderWidget = new QWidget;
m_InfoWidget = new QWidget;
m_MainWidget = new QWidget;m_HBoxLayout = new QHBoxLayout; m_VBoxLayout = new QVBoxLayout; m_RenderWidget->setAttribute(Qt::WA_PaintOnScreen); m_PhysicsConfWidget->setModel(m_PhysicsConfModel); m_VBoxLayout->addWidget(m_PhysicsConfWidget); m_VBoxLayout->addWidget(m_ObjectListWidget); m_InfoWidget->setLayout(m_VBoxLayout); QWidget* x = new QWidget; m_HBoxLayout->addWidget(m_InfoWidget); m_HBoxLayout->addWidget(x); m_MainWidget->setLayout(m_HBoxLayout); resize(800, 600); setCentralWidget(m_MainWidget);
}@
!http://s30.postimg.org/j0wynmckx/image.png(no image)!
-
The sample SGaist posted should work. In your screen capture the right side is a little wider then the left so I think it is there but there it has no reason to be wider than what it is.
A small variation to test this assumption:
@
m_ObjectListWidget = new QListWidget;
m_PhysicsConfWidget = new QTableView;
m_RenderWidget = new QWidget;
m_MainWidget = new QWidget;m_RenderWidget->setMinimumWidth(100); m_VBoxLayout = new QVBoxLayout; m_VBoxLayout->addWidget(m_PhysicsConfWidget); m_VBoxLayout->addWidget(m_ObjectListWidget); m_HBoxLayout = new QHBoxLayout(m_MainWidget); m_HBoxLayout->addLayout(m_VBoxLayout); m_HBoxLayout->addWidget(m_RenderWidget); setCentralWidget(m_MainWidget);
@