[Solved]QWidget default layout.
-
wrote on 22 Sept 2012, 10:20 last edited by
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.
-
wrote on 22 Sept 2012, 12:26 last edited by
Widgets have no layout set by default, you give them one by using QWidget::setLayout(QLayout*)
-
wrote on 22 Sept 2012, 12:33 last edited by
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.
-
wrote on 22 Sept 2012, 12:37 last edited by
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
-
wrote on 23 Sept 2012, 06:14 last edited by
[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.
1/5