PDA

View Full Version : Updating MainWindow from slot



Barry79
11th May 2009, 14:28
Hi,

I have the following slot -



QObject::connect(ui.addCasePushButton, SIGNAL(clicked ()), this, SLOT(browseToCaseFile()));

void SelectCaseWindow::browseToCaseFile()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Browse to Case File"), "/home/", tr("Case Files (*.cas)"));

repaint();

// if a file is selected
if(!fileName.isEmpty())
localCaseList->addLocally(QDir(fileName));
}


The problem is that addLocally takes about 20 seconds to process. As a result, there is a grey patch over the SelectCaseWindow where the file dialog was, which disappears after the slot function completes. What can I do to update this region of the screen before I call addLocally? The repaint doesn't seem to do anything.

I'm working on Ubuntu 9.04.

Thanks,

Barry.

Lykurg
11th May 2009, 14:32
Try to call
qApp->processEvents() before you call addLocally. You may also have a look at QApplication::setOverrideCursor().

faldzip
11th May 2009, 15:44
read this: http://doc.trolltech.com/qq/qq27-responsive-guis.html