[Resolved] Qt widget design problem



  • 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.



  • For Such Layout You can simply use QTabWidget and QPushButton.



  • 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.



  • To do so you can use setGeometry(int x,int y,int w,int h) property of the QTabWidget as well as QPushButton .



  • 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



  • 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?



  • 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!



  • Hi Tabi and NicuPopescu,

    Thank you for useful information. I'll try these ways and report back.



  • Hi Tabi and NicuPopescu,

    I tried, both of ways resolve my problem. You guys are awesome.

    Thanks again. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.