Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QProgressDialog
QtWS25 Last Chance

Problem with QProgressDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.3k Views
  • 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 Offline
    L Offline
    ldl_0
    wrote on last edited by ldl_0
    #1

    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
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      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
      0
      • kshegunovK 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.

        L Offline
        L Offline
        ldl_0
        wrote on last edited by
        #3

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

        kshegunovK 1 Reply Last reply
        0
        • L ldl_0

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

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved