Qt Forum

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

    Solved How to change size of QDialog??

    General and Desktop
    3
    12
    15176
    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.
    • QT-static-prgm
      QT-static-prgm last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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 Reply Quote 2
        • QT-static-prgm
          QT-static-prgm last edited by

          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

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @QT-static-prgm last edited by

            @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 Reply Quote 0
            • Q
              QtVik @mrjj last edited by

              @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

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @QtVik last edited by

                @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 Reply Quote 0
                • Q
                  QtVik @mrjj last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • Q
                    QtVik @mrjj last edited by 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

                    mrjj 1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion @QtVik last edited by

                      @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 Reply Quote 2
                      • Q
                        QtVik @mrjj last edited by

                        @mrjj Thank you so much :) It worked!

                        mrjj 1 Reply Last reply Reply Quote 1
                        • mrjj
                          mrjj Lifetime Qt Champion @QtVik last edited by

                          @QtVik

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

                          Q 1 Reply Last reply Reply Quote 0
                          • Q
                            QtVik @mrjj last edited by

                            @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 Reply Quote 0
                            • First post
                              Last post