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. [SOLVE] How to show QFileDialog at center position Screen?

[SOLVE] How to show QFileDialog at center position Screen?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 5.5k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    phamvanan
    wrote on last edited by
    #1

    Hi guys,
    Please tell me know, how to show @QFileDialog @at center position Screen.
    Thanks in advance.

    -PVA-

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vittalonline
      wrote on last edited by
      #2

      hi phamvanan ,

      check this code , its working fine
      @
      QFileDialog *dialog = new QFileDialog(this);
      QDesktopWidget desk;
      QRect screenres = desk.screenGeometry(0);
      dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
      dialog->show();
      @

      1 Reply Last reply
      0
      • P Offline
        P Offline
        phamvanan
        wrote on last edited by
        #3

        Hi,
        Thank you for your answer,
        Your code is working fine, I try to dialog->openFileName(); but it do not show center screen.
        Please check again for me.

        -PVA-

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Hi,

          the right way is
          @
          QFileDialog *dialog = new QFileDialog(this);
          QDesktopWidget desk;
          QRect screenres = desk.screenGeometry(0); dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
          dialog->exec();
          @

          If you call getOpenFileName() a new QFileDialog instance willbe created

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            phamvanan
            wrote on last edited by
            #5

            My code:
            @ QFileDialog dialog = new QFileDialog(this);
            QDesktopWidget desk;
            QRect screenres = desk.screenGeometry(0);
            dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
            //dialog->exec();
            outFile = QFileDialog::getOpenFileName(dialog,
            "Title Dialog"),path,
            tr("ISO(
            .iso .ISO);;All Files(.*)")
            );@
            But it's not showing center screen.

            -PVA-

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by
              #6

              HI,

              how I wrote in previous post, if you call getOpenFileName, a new Dialog instance will be created.

              TRY this

              @
              QFileDialog dialog(this);
              dialog.setFileMode(QFileDialog::AnyFile);
              dialog.setNameFilter ( tr("ISO(.iso .ISO);;All Files(.)") );

              QDesktopWidget desk;
              QRect screenres = desk.screenGeometry(0);
              dialog.setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));

              if (dialog->exec())
              outFile = dialog.selectedFiles()[0];
              @

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0
              • P Offline
                P Offline
                phamvanan
                wrote on last edited by
                #7

                Thanks for your help,
                I want use getOpenFileName(....) function so it show with Window's OpenFileDialog , not Qt's OpenFileDialog.----
                How to show center monitor but use Window's Dialog
                Thanks.

                -PVA-

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  whenever you are using native dialogs (see the docs if you are unsure) you have no control over the dialogs ... using Qt methods.

                  Nevertheless i think it would be maybe possible to write the platform-dependent code yourself to show the native dialog (e.g using WinAPI)

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  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