PDA

View Full Version : QStackedLayout dialog flicker



ArkKup
16th November 2012, 23:40
Hi,

I was trying out example about Stacked Layouts from the book "C++ GUI Programming with Qt 4, Second Edition" its Chapter 6.



PreferenceDialog::PreferenceDialog(QWidget *parent)
: QDialog(parent)
{
...
listWidget = new QListWidget;
listWidget->addItem(tr("Appearance"));
listWidget->addItem(tr("Web Browser"));
listWidget->addItem(tr("Mail & News"));
listWidget->addItem(tr("Advanced"));

stackedLayout = new QStackedLayout;
stackedLayout->addWidget(appearancePage);
stackedLayout->addWidget(webBrowserPage);
stackedLayout->addWidget(mailAndNewsPage);
stackedLayout->addWidget(advancedPage);
connect(listWidget, SIGNAL(currentRowChanged(int)),
stackedLayout, SLOT(setCurrentIndex(int)));
...
listWidget->setCurrentRow(0);
}




void MainWindow::configurationOptions()
{
PreferenceDialog *optionsDlg = new PreferenceDialog();
optionsDlg->exec();
delete optionsDlg;
}



The problem is that when I start the example I see ugly flicker on a dialog, hence my question how can this be eliminated ? I have try to use resize to make the dialog bigger by default but that didn't help.

ChrisW67
17th November 2012, 05:04
You'll have to define "ugly flicker" and when exactly you see it. Reizing the dialog, switching pages, as you type, one one particular page etc. Does the Config Dialog Example display similar flickering?

ArkKup
17th November 2012, 12:16
sorry for not being too specific by "ugly flicker" I meant that the dialog windows shows and I can see that its being resize quickly.
Config Dialog Example works just fine.

amleto
17th November 2012, 17:42
as an aside, please don't write code like this


void MainWindow::configurationOptions()
{
PreferenceDialog *optionsDlg = new PreferenceDialog();
optionsDlg->exec();
delete optionsDlg;
}

We are not java programmers... Instead write


void MainWindow::configurationOptions()
{
PreferenceDialog optionsDlg
optionsDlg.exec();
}

Shorter, quicker, easier to read, less prone to errors.