Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Problem with QProgressDialog

    General and Desktop
    2
    4
    1178
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      ldl_0 last edited by ldl_0

      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");
      dialog->setWindowModality(Qt::ApplicationModal);
      dialog->adjustSize();
      dialog->setValue(5);
      

      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.

      1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators last edited by kshegunov

        Hello,
        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.

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

        Read and abide by the Qt Code of Conduct

        L 1 Reply Last reply Reply Quote 0
        • L
          ldl_0 @kshegunov last edited by

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

          kshegunov 1 Reply Last reply Reply Quote 0
          • kshegunov
            kshegunov Moderators @ldl_0 last edited by

            @ldl_0
            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.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post