Problem with QProgressDialog

  • I get some problems with QProgressDialog. I'm using qt 4.8.5.

    1. How to adjust the size of the dialog to fit its contents?
      I test with code below:
    QProgressDialog* dialog = new QProgressDialog("Message", "Close", 0, 10);
    dialog->setWindowTitle("Long Long Long Long Title");
    dialog->setCancelButtonText("Long Long Long Click this button to cancel");

    The title and the cancel button text are cut. I called adjustSize(), but it didn't work.

    2.How to disable the maximum button (fixed size) on Mac?
    I'm using qt 4.8.5. On Windows I can set fixed size flag to a dialog with

    setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint)
    Is there similar way to set fixed size dialog on Mac? I don't want to use setFixedSize() method to hard-code the dialog size. I want to disable the maximum button and make the dialog size fixed.

  • Qt Champions 2016

    Do you have a layout set for your dialog, what does dialog()->layout() return? If you intend on using it as a modal dialog, I think you should use dialog.exec().
    I don't know whether there's a hint for mac, but as a last resort you could subclass the dialog and in a show event reimplementation call the setFixedSize() method. Disabling the button (there was some kind of a hint/attribute for that but I can't seem to find it now) doesn't necessarily mean that the dialog will be fixed size.

    Kind regards.

    Aha, I found them:
    Qt::WindowSystemMenuHint, Qt::WindowMinimizeButtonHint, Qt::WindowMaximizeButtonHint, Qt::WindowMinMaxButtonsHint and the like I believe are what you're looking for.

  • Thanks @kshegunov. These hints work on windows, but dont work on mac. And the QProgress Dialog class is provided by qt.

  • Qt Champions 2016

    Well, the hints are just that - a hint to the underlying window manager, so if it doesn't respect/support the hints you pass it there's little you can do. As for the other question, I did mention that you can subclass it as a last resort measure. If nothing works you could, of course, make your own form and initialize a generic QDialog from it, then connect the appropriate signals for the buttons and the like (maybe this is even better than inheriting the QProgressDialog). Also as a side note, if you're using a modal dialog, there's no real point in creating it in the heap.

    Kind regards.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.