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. Is there a way that I can force the native dialog with QFileDialog?
QtWS25 Last Chance

Is there a way that I can force the native dialog with QFileDialog?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 13 Sept 2013, 07:02 last edited by
    #1

    I'm working under Windows 7, Qt 5.1. I see the following behaviour:
    When I start the application from the commandline, I get the native dialog. However, when the application is started by another application via the Windows API (CreateProcess(); ) I always get the Qt internal dialog.

    I see that there is an option to prevent the native dialog QFileDialog::DontUseNativeDialog but is there a way to force the native dialog?

    Edit:
    The reason why I want to force the native dialog can be seen in "my other post here":http://qt-project.org/forums/viewthread/32484/

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbnoimi
      wrote on 15 Sept 2013, 22:12 last edited by
      #2

      As far as I know using static function will use the native dialog so did you try to use the static function?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 16 Sept 2013, 05:54 last edited by
        #3

        My question is: Is it possible to force the native dialog. Not the other way around.

        To answer your question: I did use both. You can have the native dialog also with not the static function(s). Both of the functions below give the exact same native file dialog on Windows 7. (You can "force" the Qt dialog for both of them by passing the QFileDialog::DontUseNativeDialog flag, but that's not the scope for now.)

        @
        // static
        void MainWindow::on_pushButton_clicked()
        {
        QFileDialog::getOpenFileName(0,"test","text");
        }

        // Object
        void MainWindow::on_pushButton_2_clicked()
        {
        QFileDialog * dialog = new QFileDialog();
        dialog->exec();
        delete dialog;
        }
        @

        The strange thing happens when you start the application from another process with the windows API functions CreateProcess(). Then you always get the Qt dialog.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbnoimi
          wrote on 16 Sept 2013, 10:48 last edited by
          #4

          [quote]The strange thing happens when you start the application from another process with the windows API functions CreateProcess(). Then you always get the Qt dialog. [/quote]
          I suggest to file a bug report about this issue https://bugreports.qt-project.org/

          Personally I advice you to get rid of Windows API unless you couldn't find any alternatives in Qt (ex. for you example use QProcess)

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on 16 Sept 2013, 12:03 last edited by
            #5

            I'll create a bug report. But I think I'll need to investigate the real issue a bit more deeply before doing it.

            I absolutlely agree with your advice, but this is not a viable option at the moment.
            How should I convince the other programmer of changing his code since the "bug" seems to be on my side of the code?
            The function call is in a lightweight library. Pulling in Qt there is an overkill and QProcess is not found in non-Qt. I would have to check other solutions first (like posix threads, boost threads etc...) and there's the possibility that the source of the issue is even from before the library.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbnoimi
              wrote on 16 Sept 2013, 12:10 last edited by
              #6

              [quote] How should I convince the other programmer of changing his code since the “bug” seems to be on my side of the code?[/quote]
              If that programmer insist to use the API while Qt has encapsulated most API calls; I'll encourage him to leave Qt and hack around another toolkit (ex. For Windows he can use stupid MFC)

              1 Reply Last reply
              0

              2/6

              15 Sept 2013, 22:12

              topic:navigator.unread, 4
              • Login

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