[Qt-interest] qprocess related with qprogressbar
Sean Harmer
sean.harmer at maps-technology.com
Sat Jun 27 13:14:00 CEST 2009
Hi,
mierdatutis mi wrote:
> Many thanks Sean but I try to follow your instructions and it gives me
> an error when I do progress->show(); when the process started.I do:
<snip>
>
>
> MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
>
> : QMainWindow(parent, f)
>
> {
>
> setupUi(this);
>
> proc2 = new QProcess( this );
>
> QProgressDialog *progress = new QProgressDialog( this );
>
This is the same type of error that you made yesterday. Do not declare
another QProgressDialog here with the same name as you rmember as it
hides the member variable in this scope. So your member variable is
never getting a valid address.
I recommend that you give your member variables some prefix to
distinguish them from local variables. e.g. m_progress or m_proc.
Also, be sure to initialise your member variables in the initialiser
list of the c'tor. e.g.
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f),
m_proc2( 0 ),
m_prgress( 0 )
{
m_progress = new QProgressDialog( this );
...
}
Again, this is basic C++ stuff really and is not specific to Qt.
ATB,
Sean
More information about the Qt-interest-old
mailing list