PDA

View Full Version : Dialog Update before shown



winder
27th February 2010, 17:28
hello all

i've made a dialog, wich holds some qlabels and a porgress bar. When the user presses the ok button, the progress bar starts, the buttons get disabled and when the progress is finished the dialog is hidden.

When the dialog reopens, it must be cleared... meaning, active buttons, progress bar back to value of 0. This clearing is done right begore the dialog is re-shown.

The problem is, tha although the code is like this...


m_probar->setValue(0);
m_importButton->setEnabled(true);
m_cancelButton->setEnabled(true);
exec();


i see the opossite behavior. I see a rapid change on dialog graphics, just wheni re-open it. This means that the dialog is shown before the values are set.

Any advice?

thanks in advance

Lykurg
27th February 2010, 17:53
where is your sample code inside your application? Maybe you can call update() before executing. But normally a code like that works for me:
void Foo::showDlg()
{
if(!m_dlg)
m_dlg = new SubclassedDlg(this);
m_dlg->setAllValuesToTheirDefault();
m_dlg->exec();
}
without "flashing".

winder
27th February 2010, 19:33
i'm doing exactly what you do in your example code...

No matter where i call exec() the result is the same. Flashing. It seems that the dialog draws it self just like it was when it was hidden... and then refreshes... weird :/


void Dlg::initImport(QString &path)
{
m_filepath = path;
setDefaults();
update();
exec();
}

void Dlg::setDefaults()
{
m_probar->setValue(0);
m_importButton->setEnabled(true);
m_cancelButton->setEnabled(true);
}

void Dlg::accept()
{
m_importButton->setEnabled(false);
m_cancelButton->setEnabled(false);

m_probar->setValue(100);
hide();
}

void Dlg::reject()
{
clearData();
hide();
}

Lykurg
27th February 2010, 19:50
Try to call QDialog::accept() and QDialog::reject() instead of only hiding. May be that sloves the problem. If not I am out of ideas at that point.