PDA

View Full Version : QProgressDialog and forceShow(), how to use this protected member?



mattia
22nd January 2008, 14:52
Hello, i got a problem with QProgressDialog, i'd like to show quickly the QProgressDialog but i get this error:


/usr/local/Trolltech/Qt-4.3.2-commercial-static/include/QtGui/qprogressdialog.h:101: error: ‘void QProgressDialog::forceShow()’ is protected

here down the code


QProgressDialog progress ( tr ( "Sending configuration..." ) , tr ( "Abort" ) , 0 , commandNumber , this );
progress.setWindowTitle ( tr ( "Sending configuration..." ) );
progress.setWindowModality ( Qt::NonModal );
progress.setMinimumDuration(0);
progress.forceShow(); // <-- error forceShow() is protected

thx

jpn
22nd January 2008, 15:01
That's right, it's protected and not intended to be called like that. Did you read what QProgressDialog::forceShow() does? Just set minimum duration to 0.

mattia
22nd January 2008, 15:15
ok I read, but my bar isn't showed, i post whole the code, maybe i have some error in


QProgressDialog progress ( tr ( "Sending configuration..." ) , tr ( "Abort" ) , 0 , commandNumber , this );
progress.setWindowTitle ( tr ( "Sending configuration..." ) );
progress.setWindowModality ( Qt::NonModal );
progress.setMinimumDuration(0);

for ( int i=0 ; i < commandNumber ; i++ )
{
QApplication::processEvents();

// set the progress bar
progress.setValue ( i );

// check if user choose to abort operation
if ( progress.wasCanceled () )
{
return false;
}
}

progress.setValue ( commandNumber );

edit:
i checked again, it works ;)