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. [SOLVED] QTreeview Double Clicked "The program unexpectedly finished"

[SOLVED] QTreeview Double Clicked "The program unexpectedly finished"

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtreeviewqfilesystemmodedoubleclick
23 Posts 3 Posters 12.9k 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.
  • T Offline
    T Offline
    takoo
    wrote on 1 Feb 2016, 21:43 last edited by
    #13

    Please give me example code .
    I writting at the moment from phone

    I just write code ------- (-_-) ----------

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Feb 2016, 21:51 last edited by
      #14

      Do you mean an example of calling mapToSource ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        takoo
        wrote on 1 Feb 2016, 23:16 last edited by
        #15

        Codes above

        I just write code ------- (-_-) ----------

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Feb 2016, 11:45 last edited by
          #16

          In the code above, you are trying to use an index from your proxy on your file system model. That's the problem, you have to use mapToSource in order to get the right index.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • T Offline
            T Offline
            takoo
            wrote on 2 Feb 2016, 15:20 last edited by takoo 2 Feb 2016, 19:50
            #17

            @SGaist Where will I use mapToSource ?

            I just write code ------- (-_-) ----------

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 Feb 2016, 21:31 last edited by
              #18

              In on_treeView_doubleClicked

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • T Offline
                T Offline
                takoo
                wrote on 3 Feb 2016, 10:51 last edited by
                #19

                @SGaist I wrote this code and again I get error("the has unexpectedly finished") ```
                void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
                {

                if(index.isValid())
                {
                filter->mapToSource(model->index(dir));
                qDebug()<<model->filePath(index);
                }
                }

                I just write code ------- (-_-) ----------

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 3 Feb 2016, 10:55 last edited by
                  #20

                  @takoo said:

                  Hi
                  http://doc.qt.io/qt-5.5/qsortfilterproxymodel.html#mapToSource
                  it returns a new index. I assume you should use that index.
                  you still use "old" index filePath(index);

                  QModelIndex mapped=filter->mapToSource(model->index(dir));
                  model->filePath(mapped);

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    takoo
                    wrote on 3 Feb 2016, 11:01 last edited by
                    #21

                    hi ```

                    I get error (QSortFilterProxyModel: index from wrong model passed to mapToSource)
                    void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
                    {

                    if(index.isValid())
                    {
                    QModelIndex mapped=filter->mapToSource(model->index(dir));

                        qDebug()<<model->filePath(mapped);
                     }
                    

                    }

                    I just write code ------- (-_-) ----------

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 3 Feb 2016, 11:01 last edited by
                      #22

                      oh
                      maybe its
                      mapToSource(index)

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        takoo
                        wrote on 3 Feb 2016, 11:06 last edited by
                        #23

                        Thanks everybody

                        I just write code ------- (-_-) ----------

                        1 Reply Last reply
                        0

                        22/23

                        3 Feb 2016, 11:01

                        • Login

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