Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, June 2007
about QStackedWidget and QLayout


Message 1 in thread

Hello, every one
I created a QStackedWidget named downStackedWidget and a few page widgets,
one of which is autoPageWidget. Then I add 6 QPushButton and one QLineEdit
and two QLayout to this page.
related codes as follows:
{...
        downStackedWidget->setCurrentWidget(autoPageWidget);
        openButton = new QPushButton(tr("OPEN"), autoPageWidget);
        runButton = new QPushButton(tr("RUN"), autoPageWidget);
        pauseButton = new QPushButton(tr("PAUSE"), autoPageWidget);
        resumeButton = new QPushButton(tr("RESUME"), autoPageWidget);
        stepButton = new QPushButton(tr("STEP"), autoPageWidget);
        verifyButton = new QPushButton(tr("VERIFY"), autoPageWidget);
        programTextEdit = new QTextEdit(autoPageWidget);
        programTextEdit->setReadOnly(true);
        QHBoxLayout *hLayout = new QHBoxLayout;
        hLayout->addWidget(openButton);
        hLayout->addWidget(runButton);
        hLayout->addWidget(pauseButton);
        hLayout->addWidget(resumeButton);
        hLayout->addWidget(stepButton);
        hLayout->addWidget(verifyButton);
        hLayout->setMargin(0);
        hLayout->setSpacing(0);
        QVBoxLayout *vLayout = new QVBoxLayout;
        vLayout->addLayout(hLayout);
        vLayout->addWidget(programTextEdit);
        vLayout->setMargin(0);
        vLayout->setSpacing(0);
        autoPageWidget->setLayout(vLayout);
}
No error came out when I 'make' it in xterm. But when I run it, nothing
appears.
What's the problem do you think?
-- 
 [ signature omitted ] 

Message 2 in thread

On Saturday 02 June 2007, ååä wrote:
>         downStackedWidget->setCurrentWidget(autoPageWidget);

You need to use addWidget first to add the widget to the stack. 
setCurrentWidget only looks through the already added children of the 
stacked layout and brings the given one to the foreground (if it is known).


	Konrad

Attachment:

Attachment: pgp2X10eHLvXu.pgp
Description: PGP signature