Nominate our 2022 Qt Champions!

How to programmatically resize QProgressDialog

  • I create QProgressDialog but from parent window but I would like the default size to be be little bigger than what it comes up with. How can I change that?

    @ progress = (QSharedPointer<QProgressDialog>) new QProgressDialog("Creating files...", "Cancel", 1, numFiles, this, Qt::Dialog) ;
    progress->setAutoClose( false );
    progress->setModal( true );
    progress->setAutoReset( false );@

  • Moderators

    progress->resize(progress->size() + QSize(20. 20));

  • That somehow doesn't compile! I had to do the following along similar lines as you did but I don't know why your line doesn't compile:

    @ QSize size = progress->size(); //+ QSize(20. 20);
    size.setWidth( size.width() + 180);
    progress->resize( size );@

  • Lifetime Qt Champion


    What error did you got ?

  • The problem is the point in the QSize constructor.

    Try using comma instead:
    @progress->resize(progress->size() + QSize(20, 20));@

  • Moderators

    [quote author="euchkatzl" date="1424342793"]The problem is the point in the QSize constructor.[/quote]

    Oops, indeed, a typo. My bad.

  • Yes that was it! I just copy/pasted it and didn't realize it should be comma but that fixed it.

Log in to reply