[Resolved] Qt widget design problem
-
wrote on 29 Oct 2013, 06:21 last edited by
Hi,
I'm quite new with Qt layout and want to have my Qt widget based application designed like this:
"Please see described image here":http://farm4.staticflickr.com/3710/10549869363_bb7257b566.jpg
I searched and tried some kinds of layout such as grid layout, vertical layout,... but I cant find any way to do that. Please help me.
Thank for your help.
P/S: The described image is not shown event I tried some photo sharing services. Finally, I have to use link instead. Sorry for this.
-
wrote on 29 Oct 2013, 06:42 last edited by
For Such Layout You can simply use QTabWidget and QPushButton.
-
wrote on 29 Oct 2013, 06:47 last edited by
Thank you IamSumit,
I think my question is not enough clear to understand. I mean I don't know how to position these widgets(QTabWidget and QPushButton as you told) on QMainWindow like described image. I tried grid layout, vertical layout,... but I cannot.
-
wrote on 29 Oct 2013, 06:56 last edited by
To do so you can use setGeometry(int x,int y,int w,int h) property of the QTabWidget as well as QPushButton .
-
wrote on 29 Oct 2013, 07:17 last edited by
The buttons alligned with tab bar possible only with setting up corner widget in QTabWidget. Make your own widget that have two or more pushbuttons and add it as the cornerwidget or QTabwidget. It will give you expected layout or widget.
Refer this:
http://qt-project.org/doc/qt-5.0/qtwidgets/qtabwidget.html#setCornerWidget -
wrote on 29 Oct 2013, 07:18 last edited by
Hi IamSumit,
Yes, you're right. I can do so by Qt designer too but without using layout. Unfortunately, if don't use layout I cannot have my app's GUI expandable or resize when user minimize or maximize app's window .
Do you have any idea?
-
wrote on 29 Oct 2013, 16:25 last edited by
I'm afraid by layout and designer you cannot since the widget's bound rectangles overlapp ... but with little piece of code you get what you need:
@QPushButton* button = new QPushButton(ui->tabWidget);
button->resize(ui->tabWidget->geometry().width()/4,tabBar->tabRect(0).height());
button->move(ui->tabWidget->rect().right()-button->width(),0);
button->setText("Start");@buttons can be created by designer and in code just use setParent(tabWidget)
hope it helps!
Cheers!
-
wrote on 30 Oct 2013, 01:18 last edited by
Hi Tabi and NicuPopescu,
Thank you for useful information. I'll try these ways and report back.
-
wrote on 30 Oct 2013, 09:00 last edited by
Hi Tabi and NicuPopescu,
I tried, both of ways resolve my problem. You guys are awesome.
Thanks again. :)
1/9