I want to do universal method to set position of my widget. All I wanna get it is set right coordinates for my widget wich must always be in right bottom corner of desktop. My widget can change his height (or maybe width) but it must have adjusted size by both ordinates... (too many words)
我的想法是使用QDesktopWidget作为基本的小部件,将stratch项放入我的QLayout中(将内部(我的)小部件左右对齐)
我的代码原型在这里:
QDesktopWidget * desktopWidget = QApplication::desktop();
MyWidget * myWidget = new MyWidget(desktopWidget);
QVBoxLayout * vlayout = new QVBoxLayout;
vlayout->addStretch();
vlayout->addWidget(myWidget);
QHBoxLayout * hlayout = new QHBoxLayout(desktopWidget);
hlayout->addStretch();
hlayout->addLayout(vlayout);
但它不起作用。。。
Help me please implement my idea if you know how. At this moment I know only one work way to do it - it is manually set pos of widget and handle many events (resize etc.) - but this is not good... (because i do it bad of cause ;-) )
附言:在其他小部件中使用qlayout的想法是有效的,例如在视图的certer处使用带有沙时钟的QTextBrowser等。