[Solved]QWidget default layout.



  • Hi,

    I am working on creating a custom layout using layout manager. I have gone through the implementation of "Border Layout":http://doc.qt.digia.com/4.7-snapshot/layouts-borderlayout.html , "Card Layout":http://doc.qt.digia.com/4.7-snapshot/layout.html and "Flow Layout":http://doc.qt.digia.com/4.7-snapshot/layouts-flowlayout.html . I want to know what is the default layout for a QWidget and where can i find the implementation code. As my custom layout should have similar features to the default layout.

    Thanks.



  • Widgets have no layout set by default, you give them one by using QWidget::setLayout(QLayout*)



  • Nops thats not what i am looking for, By default if I add a widget to a QWidget and i dont set any layout then I can move the widget to any location or i can set the position using setGeometry(x,y,..,..)

    So if i add a label to the widget like

    @QLabel *label = new QLabel(this);
    label->setGeometry(100,150,50,25);@

    It adds the label to the layout.

    QMainWindow also uses qmainwindowlayout internally.



  • That is not using layouts, that's just painting fixed-sized and fixed-placement widgets.
    I'll show you what I mean:
    @
    int main(int argc, char** argv) {
    QApplication app(argc, argv);
    QWidget w;
    QWidget w2(&w);
    std::cout << w.layout() << std::endl;
    }
    @

    Output: 0



  • [quote author="Terence" date="1348317435"]That is not using layouts, that's just painting fixed-sized and fixed-placement widgets.
    I'll show you what I mean:
    @
    int main(int argc, char** argv) {
    QApplication app(argc, argv);
    QWidget w;
    QWidget w2(&w);
    std::cout << w.layout() << std::endl;
    }
    @

    Output: 0[/quote]

    Thanks I understood that and have gone through the code as well of QWidget. With the help of other documentation and examples I am able to create my own custom layout.


Log in to reply
 

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