Layout issue in the window.
-
Hi all,
I have a problem in making layout to my MainWindow. Mainwinbdow is having manu bar , tool bar on the top and the rest space has to be occupied by three things. I planned to keep fixed postion tabwidget on left side, next to it I need to show multiple docks in using grid layout and the property dock widget at the right side. I added a image so that to get good imagination on my problem.Can some please the best way to make a suitable layout. I tried HBoxlayout, VBoxLayout,GridLAyout. Might be am on wrong trck..Someone please suggest to do this.
[https://www.dropbox.com/s/1b1fgt8g8cj88h2/mainlayout image.PNG?dl=0 ](link url)thanks,
Sumi -
Hi there,
Instead of a QTabWidget on the left side, you could use a QListView linked to a QStackedLayout
Not sure this is what you need, but you can achieve this kind of interface:
https://www.dropbox.com/s/bu56ww44y9du3is/QStacked1.png?dl=0Basically you can hide/show multiple QWidget on the QStackLayout depending on the selection of the QListView.
Good luck! -
Hi Mr.Maximus,
I need a Tabwidget with two tabs, each tab holds different controls. Could you please have a look on my link.'SO that you will get an idea.
thanks for your advice.
Please have look on the image attached here.https://www.dropbox.com/s/803li7jw83j7kwk/mainlayoutopengl.PNG?dl=0
thanks,
Sumi. -
Thank you for the picture.
You could have a ListView on the left replacing the TabWidget, then 2 QStackWidget on the right.
Would be best if you could show the interaction with the 3 UI at the bottom so we can understand better what you need. Hand written UI works fine for saving time :) -
Thank you Mr. Maximus,
In the moment I don't have full stuff to show. But I can explain the whole thing for better understanding of my problem. But approximately I will going to some stuff some like this. Please have a look on controls and visualization window. In my case I also will be having another dock on Right side. Thid right side dock will also make communication Visualization screen,
https://www.dropbox.com/s/99tf0o2o86u4kte/Mainlayout.PNG?dl=0
Might after end of the code.It might look this stuff
https://www.dropbox.com/s/ovepkozf07nw2lc/threeclusters_.bmp?dl=0
thank in advance,
Sumi -
Here is part of my code:
mainwindow::mainwindow()
{
Qwidget *window = new Qwidget;
size
title
creat Actions();
createmenubar();
createtoolbar();Q**** mainlayout = new Q***; ////////////////////////how to give the layout like in the linkof the above post
mainlayout->addwidget/layout (tabwidget goes here);
mainlayout->addlayout(gridodopengldocks);
mainlayout->addLayout(property_dock);
windows->setlayout(mainlayout)}
void mainwindow:: createmenubar()
{
//menu stuff file edit blah etc
}
void mainwindow::createtoolbar()
{
fonttoolbar->addaction***** blah
}
void mainwindow::create_tabW_widget_container()
{
}
void mainwindow::createdocks_for_opengl()
{
Qgridlayout *gridodopengldocks = new QGridlayout;
Qdockwidget 'dock = new Qdockwidget;
QOpenGLWidget *glwidget = new QopenglWidget;
dock->addwidget(glWidget);
}void mainwindow::createporperty()
{
Qdockwidget 'prop_ock = new Qdockwidget;
property_dock->setpositon (Right..)}
-
Oh I see now.
You only need a QHorizontalLayout a the bottom for your 3 QWidgets
So basically:
- Set Main Layout to a Vertical Layout
- Insert Menu Bar, Tool, bar, specifiy a maximum height so it doesn't take too much
- Create a Horizontal Layout, insert your 3 QWidget there
- Insert the Horizontal Layout(3) in the Vertical Layout
You can do all this in the Designer just for testing
Good luck,
Max -
Hi Maximus ,
I was trying this as you told.But it is giving me the crash. I don't know Where I did mistake.
It is giving error :: QLayout: Cannot add a null layout to QHBoxLayout/And here is code clip..
MainWindow:: MainWindow() { QWidget *window = new QWidget(); setCentralWidget(window); QHBoxLayout *HLayout = new QHBoxLayout; HLayout->addLayout(tabbox ); HLayout->addLayout(grid); HLayout->addLayout(docks); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(HLayout); window->setLayout(mainLayout); createActions(); createMenus(); createToolBar(); createPropertyDock(); createtabwidget(); createDockWidget(); QString message = tr("A context menu is available by right-clicking"); statusBar()->showMessage(message); setWindowTitle(tr("Mainwindow")); setMinimumSize(160, 160); resize(1200, 800); } void MainWindow :: createPropertyDock() { QHBoxLayout *docks =new QHBoxLayout; QDockWidget *dock = new QDockWidget(tr("Properties"), this); docks->addWidget(dock); dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, dock); } void MainWindow :: createtabwidget() { QHBoxLayout *tabbox = new QHBoxLayout; QTabWidget *tabWidget = new QTabWidget; tabbox->addWidget(tabWidget); tabWidget->setTabPosition(QTabWidget::West); tabWidget->setSizePolicy(QSizePolicy ::Fixed , QSizePolicy ::Fixed); //tabWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); tabWidget->setMinimumSize(256,1160); tabWidget->setMaximumSize(256,1160); } void MainWindow::createDockWidget() { QGridLayout *grid = new QGridLayout; QDockWidget *dw = new QDockWidget; grid->addWidget(dw); dw->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); dw->setWidget(new QOpenGLWidget); }
thnaks in advance ,
Sumi[edit: Added missing coding tags ``` SGaist]
-
@N.Sumi said:
Hi, just a question.
in
void MainWindow :: createtabwidget()
you create the local variable:
QHBoxLayout *tabbox = new QHBoxLayout;
and in
MainWindow:: MainWindow()
Layout->addLayout(tabbox );If they are the same ?, then tabbox should live in MainWindow class and it should be
tabbox = new QHBoxLayout;
in createtabwidget()
My guess is that you did declare them in .h but made a local var by accident. ? -
Hi,
If it crashes, a simple run through the debugger will tell you where exactly it misbehave