PDA

View Full Version : Do you have to use Layout management to show the QwizardPage contents?



litroncn
28th May 2008, 11:18
I create a page named TestPage, this is its constructor:

TestPage::TestPage(QWidget *parent)
:QWizardPage(parent)
{
QPushButton *button = new QPushButton("Start");
QVBoxLayout *layout = new QVBoxLayout;

layout->addWidget(button);
setLayout(layout);
}
When I run it, the button appears on the page. However, if I do the following…

TestPage::TestPage(QWidget *parent)
:QWizardPage(parent)
{
QPushButton *button = new QPushButton(this);
}
…the button is invisible. So, to show the page contents do I need to use layout management? Or is there another way to implement displaying a button or other widgets without using layout management ?

Thanks in advance

jpn
28th May 2008, 17:28
To put it other way around, why wouldn't you use layout management?

litroncn
30th May 2008, 08:26
Thanks for the reply!

I am running into some problems using layout management. I have attached a picture for reference. I display a PCB image in a Qlabel, and have added six other Qlabel objects in the foreground. I used Qlabel->setPixmap to draw the blue rectangles on top of the background, and I want the six rectangles to be able to change their properties, such as color, at a fixed rate which will inidicate the card’s status. I’ve had some trouble using layout management to arrange my widgets like this. Is it possible to arrange my widgets like that using layout management, or is there some other way to implement what I have specified?

Any suggestions would be appreciated!

wysota
30th May 2008, 08:37
I'd implement it as a single custom widget, but you can also create a custom layout or reimplement resizeEvent() for your widget and move the items around yourself using QWidget::setGeometry(). It should be also achievable using a grid layout with spacers.