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. Take an index and get a real path
Qt 6.11 is out! See what's new in the release blog

Take an index and get a real path

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    ShylerC
    wrote on last edited by
    #1

    Team,

    Program lays out the files.
    I click one; the index changes.

    It outputs something like this

    QModelIndex(1,0,0x561bc4b7f970,QFileSystemModel(0x561bc46ac870))

    Is it possible to convert the above and turn it to ---

    /home/User/Desktop/file.txt

    Just curious. If I can't I'll keep plugging away.

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

      Hi,

      Do you mean QFileSystemModel::filePath ?

      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
      3
      • S Offline
        S Offline
        ShylerC
        wrote on last edited by
        #3

        I would assume so - however I am such a noob I can't figure out how to take the selection from treeview and pull the fully qualified path. All I can get is the signal from ui->treeView->currentIndex();

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What exactly are you trying to achieve ?

          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
          • S Offline
            S Offline
            ShylerC
            wrote on last edited by
            #5

            Pick a file from treeview- on mainwindow, take the path of file from qtreeview; turn it into a string and perform functions on the file.

            Lost on

            ui->treeview->//do I use currentIndex() ? Or is there a filepath function specifically for this?

            I havent tried to modify with the index output. I figured You had to have the correct path.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You should use your view's selection model and connect the currentChanged signal to the slot where you want to do the processing you need. In that slot, use the QFileSystemModel::filePath method I suggested earlier.

              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
              2

              • Login

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