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. How to get acess to timestamp of a file in QListView
Forum Updated to NodeBB v4.3 + New Features

How to get acess to timestamp of a file in QListView

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 658 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.
  • AzadshahrA Offline
    AzadshahrA Offline
    Azadshahr
    wrote on last edited by Azadshahr
    #1

    I have a QListView widget which shows the contents of a folder. Now I wanted to select a file in QListView and then try to get the timestamp of the selected tile. Then I wanted to show it in the QTime widget. How can I implement such a thing?

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

      Hi,

      How are you populating your list view ?

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

        I used this code to populate the list directory.

        void MainWindow::ListDirectory(QString arg_smb_path)
        {
            o_directorySystemModel = new QFileSystemModel(this);
            o_directorySystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
            o_directorySystemModel->setRootPath(arg_smb_path);
        
            ui->treeView->setModel(o_directorySystemModel);
            ui->treeView->hideColumn(1);
            ui->treeView->hideColumn(2);
            ui->treeView->hideColumn(3);
        
        
            o_fileSystemModel = new QFileSystemModel(this);
            o_fileSystemModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
            o_fileSystemModel->setRootPath(arg_smb_path);
        
            ui->listView->setModel(o_fileSystemModel);
            ui->listView->setContextMenuPolicy(Qt::CustomContextMenu);
        }
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          See QFileSystemModel::fileInfo()

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          AzadshahrA 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            See QFileSystemModel::fileInfo()

            AzadshahrA Offline
            AzadshahrA Offline
            Azadshahr
            wrote on last edited by
            #5

            @Christian-Ehrlicher Chris, Can you give me simple example?

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

              You can use the activated signal and in the slot, you'll have the index of interest and you can use the fileInfo method pointed by @Christian-Ehrlicher to retrieve the informations you want.

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

              AzadshahrA 1 Reply Last reply
              1
              • SGaistS SGaist

                You can use the activated signal and in the slot, you'll have the index of interest and you can use the fileInfo method pointed by @Christian-Ehrlicher to retrieve the informations you want.

                AzadshahrA Offline
                AzadshahrA Offline
                Azadshahr
                wrote on last edited by
                #7

                @SGaist I am new to Qt and I am not really familiar with whole thing. If you give me some example code, I can understand how should I go.

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

                  Qt is full of examples, did you take a look at them ?

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

                  AzadshahrA 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Qt is full of examples, did you take a look at them ?

                    AzadshahrA Offline
                    AzadshahrA Offline
                    Azadshahr
                    wrote on last edited by
                    #9

                    @SGaist I am new to Qt and I am not a professional c++ programmer because of that I need some real help to implement this program. I already implemented everything well but this feature has not completed yet. :(

                    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