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. How to change size of QDialog??
QtWS25 Last Chance

How to change size of QDialog??

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 21.0k 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.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    It seams that i'm too stupid to change the size of my QDialog.
    Here is the code:

    	QMessageBox* dialog = new QMessageBox(QMessageBox::Information,
    		WINDOW_NAME,
    		QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))),
    		QMessageBox::StandardButton::Close,
    		this,
    		Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    
    	dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
    	dialog->resize(500, 1000);
    	dialog->exec();
    	delete dialog;
    

    I just want to set a minimum width. But nothing works:

    	QMessageBox* dialog = new QMessageBox(QMessageBox::Information,
    		WINDOW_NAME,
    		QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))),
    		QMessageBox::StandardButton::Close,
    		this,
    		Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    
    	dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
    	dialog->setMinimumWidth(500);
    	dialog->exec();
    	delete dialog;
    

    I tried to set the sizepolicy, but i always get error messages, when i try that.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Do you mean QMessageBox ?
      It is not really supported but hacks exists.
      http://stackoverflow.com/questions/37668820/how-can-i-resize-qmessagebox
      Also see this "bug" report.
      https://bugreports.qt.io/browse/QTBUG-7851

      1 Reply Last reply
      2
      • QT-static-prgmQ Offline
        QT-static-prgmQ Offline
        QT-static-prgm
        wrote on last edited by
        #3

        Works fine. Do you know how to remove the "bling" when i use QMessageBox::Information?? I want that i icon, but i don't want it to make sound

        mrjjM 1 Reply Last reply
        0
        • QT-static-prgmQ QT-static-prgm

          Works fine. Do you know how to remove the "bling" when i use QMessageBox::Information?? I want that i icon, but i don't want it to make sound

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @QT-static-prgm said in How to change size of QDialog??:

          but i don't want it to make sound

          Hi
          Never tried it but
          http://stackoverflow.com/questions/16070012/how-can-i-disable-sounds-played-by-qt-qmessagebox

          Q 1 Reply Last reply
          0
          • mrjjM mrjj

            @QT-static-prgm said in How to change size of QDialog??:

            but i don't want it to make sound

            Hi
            Never tried it but
            http://stackoverflow.com/questions/16070012/how-can-i-disable-sounds-played-by-qt-qmessagebox

            Q Offline
            Q Offline
            QtVik
            wrote on last edited by
            #5

            @mrjj Hello

            How will you change the size of QDialog not the QMessageBox ?

            I am doing like this:
            fileDialog->resize(m_measDialogWidth, m_measDialogHeight);

            Somehow it is not setting the width and height at all.
            I am always getting the default width and height.

            Thanks

            mrjjM 1 Reply Last reply
            0
            • Q QtVik

              @mrjj Hello

              How will you change the size of QDialog not the QMessageBox ?

              I am doing like this:
              fileDialog->resize(m_measDialogWidth, m_measDialogHeight);

              Somehow it is not setting the width and height at all.
              I am always getting the default width and height.

              Thanks

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @QtVik
              Hi
              is that a Qt FileDialog or just your own QDialog based dialog ?

              If you have an UI file with your dialog, you can directly set size there.

              Q 2 Replies Last reply
              0
              • mrjjM mrjj

                @QtVik
                Hi
                is that a Qt FileDialog or just your own QDialog based dialog ?

                If you have an UI file with your dialog, you can directly set size there.

                Q Offline
                Q Offline
                QtVik
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • mrjjM mrjj

                  @QtVik
                  Hi
                  is that a Qt FileDialog or just your own QDialog based dialog ?

                  If you have an UI file with your dialog, you can directly set size there.

                  Q Offline
                  Q Offline
                  QtVik
                  wrote on last edited by QtVik
                  #8

                  @mrjj No.. it is Qt FileDialog.
                  Following is the code:
                  QFileDialog* fileDialog = new QFileDialog(this);
                  fileDialog->setWindowTitle("Open Meas File");
                  fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
                  fileDialog->setNameFilter(tr("DAT (*.dat)"));
                  fileDialog->setGeometry(this->x(), this->y(),this->m_measDialogWidth, this->m_measDialogHeight);
                  .....
                  if(fileDialog->exec())
                  {
                  .....
                  }

                  Note: m_measDialogWidth and m_measDialogHeight always has the previously set width/height

                  using setGeometry i am able to set the position but not the width and height.
                  why is that ?

                  Thanks

                  mrjjM 1 Reply Last reply
                  0
                  • Q QtVik

                    @mrjj No.. it is Qt FileDialog.
                    Following is the code:
                    QFileDialog* fileDialog = new QFileDialog(this);
                    fileDialog->setWindowTitle("Open Meas File");
                    fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
                    fileDialog->setNameFilter(tr("DAT (*.dat)"));
                    fileDialog->setGeometry(this->x(), this->y(),this->m_measDialogWidth, this->m_measDialogHeight);
                    .....
                    if(fileDialog->exec())
                    {
                    .....
                    }

                    Note: m_measDialogWidth and m_measDialogHeight always has the previously set width/height

                    using setGeometry i am able to set the position but not the width and height.
                    why is that ?

                    Thanks

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @QtVik

                    Ok. When a platform (OS) has a FileDialog, Qt uses that one.
                    Called the native Dialog and that is why the setGeometry is ignored.
                    (on linux for instance it can remember the size so it will load some size when shown)

                    You can use
                    fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);

                    and you can then resize it. but it uses Qt version of FileDialog.
                    Not the one from the OS.

                    Q 1 Reply Last reply
                    2
                    • mrjjM mrjj

                      @QtVik

                      Ok. When a platform (OS) has a FileDialog, Qt uses that one.
                      Called the native Dialog and that is why the setGeometry is ignored.
                      (on linux for instance it can remember the size so it will load some size when shown)

                      You can use
                      fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);

                      and you can then resize it. but it uses Qt version of FileDialog.
                      Not the one from the OS.

                      Q Offline
                      Q Offline
                      QtVik
                      wrote on last edited by
                      #10

                      @mrjj Thank you so much :) It worked!

                      mrjjM 1 Reply Last reply
                      1
                      • Q QtVik

                        @mrjj Thank you so much :) It worked!

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @QtVik

                        Super.
                        So i guess the Qt build in dialog is just fine for you.

                        Q 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @QtVik

                          Super.
                          So i guess the Qt build in dialog is just fine for you.

                          Q Offline
                          Q Offline
                          QtVik
                          wrote on last edited by
                          #12

                          @mrjj Yes. I had set the native Dialog option previously but resizing of the dialog was done prior to that . So it was not reflecting the changes. Thank you :)

                          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