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. QFileDialog Error
Qt 6.11 is out! See what's new in the release blog

QFileDialog Error

Scheduled Pinned Locked Moved Unsolved General and Desktop
35 Posts 5 Posters 30.3k Views 3 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by saitej
    #1

    I am using OpenFileDialog to load a file and this is the code.

     QString fileName = QFileDialog::getOpenFileName(this,
                                                        tr("Open File"),QDir::homePath() , tr("Kml Files (*.kml)"));
        qDebug() << "Loading File"<< fileName;
        QFile file( fileName );
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            return;
        QTextStream in(&file);
    

    But I am getting the dialog as shown here and so am unable to select the files. Any comments on why the filedialog is being displayed in this manner?

    Note: This is called when load file is triggered on mainwindow.Does it have anything to do with the mainwindow layout?

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

      Hi
      That seems completely messed up ?
      everything else works normally?

      Try to make small default application
      and use the file open code.

      Does it still does it then?

      saitejS 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        That seems completely messed up ?
        everything else works normally?

        Try to make small default application
        and use the file open code.

        Does it still does it then?

        saitejS Offline
        saitejS Offline
        saitej
        wrote on last edited by
        #3

        @mrjj
        No I tried the same code in a new project and it works :(

        mrjjM 1 Reply Last reply
        1
        • saitejS saitej

          @mrjj
          No I tried the same code in a new project and it works :(

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

          @saitej

          Ok. so it is your project somehow?!?

          And this happens as shoow as it open the dialog?

          Does it only do it on ubuntu?
          (the same code)

          saitejS 1 Reply Last reply
          1
          • miclandM Offline
            miclandM Offline
            micland
            wrote on last edited by
            #5

            Just a guess: What's the parent instance (this) that you pass to the QFileDialog::getOpenFileName(...) method?
            Is it an insvible window? (This should not be a problem but it seems that something influences the dialog box)
            And: Does the dialog show up in fullscreen? Does the dialog look normal when you try to resize it using the mouse?

            saitejS 1 Reply Last reply
            2
            • miclandM micland

              Just a guess: What's the parent instance (this) that you pass to the QFileDialog::getOpenFileName(...) method?
              Is it an insvible window? (This should not be a problem but it seems that something influences the dialog box)
              And: Does the dialog show up in fullscreen? Does the dialog look normal when you try to resize it using the mouse?

              saitejS Offline
              saitejS Offline
              saitej
              wrote on last edited by saitej
              #6

              @micland

              No. Its the mainwindow already holding several widgets. Yes, the dialog shows up in full screen and also I am unable to resize it from the bottom

              miclandM kshegunovK 2 Replies Last reply
              0
              • saitejS saitej

                @micland

                No. Its the mainwindow already holding several widgets. Yes, the dialog shows up in full screen and also I am unable to resize it from the bottom

                miclandM Offline
                miclandM Offline
                micland
                wrote on last edited by
                #7

                @saitej
                Hm, I think the reason for the display problem is the fact that the dialog is in fullsize mode (I'm not sure if this is really supported - on the other hand there's no reason why it should lead to a mixed up layout). And I have no idea why the dialog runs in fullscreen.
                Could you try once to pass NULL instead of this just to see if the dialog layout changes?

                saitejS 1 Reply Last reply
                1
                • miclandM micland

                  @saitej
                  Hm, I think the reason for the display problem is the fact that the dialog is in fullsize mode (I'm not sure if this is really supported - on the other hand there's no reason why it should lead to a mixed up layout). And I have no idea why the dialog runs in fullscreen.
                  Could you try once to pass NULL instead of this just to see if the dialog layout changes?

                  saitejS Offline
                  saitejS Offline
                  saitej
                  wrote on last edited by
                  #8

                  @micland

                  I tried by passing NULL and also made sure the mainwindow is not maximized but still same problem persists

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @saitej

                    Ok. so it is your project somehow?!?

                    And this happens as shoow as it open the dialog?

                    Does it only do it on ubuntu?
                    (the same code)

                    saitejS Offline
                    saitejS Offline
                    saitej
                    wrote on last edited by
                    #9

                    @mrjj

                    I tried the same code in the same system. It works on a new project but not on an existing one. I am unable to find a valid reason for this unusual behaviour

                    mrjjM 1 Reply Last reply
                    1
                    • saitejS saitej

                      @mrjj

                      I tried the same code in the same system. It works on a new project but not on an existing one. I am unable to find a valid reason for this unusual behaviour

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

                      @saitej
                      ok. its really , really odd.

                      Could you try with the
                      QFileDialog::DontUseNativeDialog
                      flag and see if its the ubuntu dialog that is strange?

                      saitejS 2 Replies Last reply
                      1
                      • mrjjM mrjj

                        @saitej
                        ok. its really , really odd.

                        Could you try with the
                        QFileDialog::DontUseNativeDialog
                        flag and see if its the ubuntu dialog that is strange?

                        saitejS Offline
                        saitejS Offline
                        saitej
                        wrote on last edited by
                        #11

                        @mrjj
                        It didn't work :(

                        mrjjM 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @saitej
                          ok. its really , really odd.

                          Could you try with the
                          QFileDialog::DontUseNativeDialog
                          flag and see if its the ubuntu dialog that is strange?

                          saitejS Offline
                          saitejS Offline
                          saitej
                          wrote on last edited by
                          #12

                          @mrjj

                          I will try to implement the same in qml. How to open file dialog in qml through a slot/function?

                          1 Reply Last reply
                          0
                          • saitejS saitej

                            @mrjj
                            It didn't work :(

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

                            @saitej

                            Same thing happens even with flag?

                            Hmm. I really have no idea what can do this.

                            Also since it works normally in default app and
                            the static call is the same.

                            Have you tried some of the other dialogs ? like COlorDIalog?

                            saitejS 1 Reply Last reply
                            1
                            • mrjjM mrjj

                              @saitej

                              Same thing happens even with flag?

                              Hmm. I really have no idea what can do this.

                              Also since it works normally in default app and
                              the static call is the same.

                              Have you tried some of the other dialogs ? like COlorDIalog?

                              saitejS Offline
                              saitejS Offline
                              saitej
                              wrote on last edited by
                              #14

                              @mrjj
                              Nope. Any links would help

                              mrjjM 1 Reply Last reply
                              0
                              • saitejS saitej

                                @mrjj
                                Nope. Any links would help

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

                                @saitej

                                Its like the getOpenFileName, just to get a color and not a filename.

                                http://doc.qt.io/qt-5/qcolordialog.html

                                I just wonder if that is funky too.

                                saitejS 2 Replies Last reply
                                0
                                • mrjjM mrjj

                                  @saitej

                                  Its like the getOpenFileName, just to get a color and not a filename.

                                  http://doc.qt.io/qt-5/qcolordialog.html

                                  I just wonder if that is funky too.

                                  saitejS Offline
                                  saitejS Offline
                                  saitej
                                  wrote on last edited by
                                  #16

                                  @mrjj

                                  @saitej said:

                                  @mrjj

                                  I will try to implement the same in qml. How to open file dialog in qml through a slot/function?

                                  I want links for this

                                  1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    @saitej

                                    Its like the getOpenFileName, just to get a color and not a filename.

                                    http://doc.qt.io/qt-5/qcolordialog.html

                                    I just wonder if that is funky too.

                                    saitejS Offline
                                    saitejS Offline
                                    saitej
                                    wrote on last edited by
                                    #17

                                    @mrjj
                                    QColorDialog works fine!!

                                    mrjjM 1 Reply Last reply
                                    0
                                    • saitejS saitej

                                      @mrjj
                                      QColorDialog works fine!!

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

                                      @saitej
                                      Ok very strange..

                                      Im not into QML but this seems to be sample
                                      http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#details

                                      saitejS 1 Reply Last reply
                                      1
                                      • mrjjM mrjj

                                        @saitej
                                        Ok very strange..

                                        Im not into QML but this seems to be sample
                                        http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#details

                                        saitejS Offline
                                        saitejS Offline
                                        saitej
                                        wrote on last edited by
                                        #19

                                        @mrjj

                                        Thanks!!

                                        I tried through QML also but am getting the same result.

                                        miclandM 1 Reply Last reply
                                        0
                                        • saitejS saitej

                                          @mrjj

                                          Thanks!!

                                          I tried through QML also but am getting the same result.

                                          miclandM Offline
                                          miclandM Offline
                                          micland
                                          wrote on last edited by
                                          #20

                                          @saitej
                                          That's really strange. Can your share a minimal runnable code example so that other users can try to reproduce the behaviour on their platforms?

                                          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