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. Creating a sort of file explorer layout in Qt
QtWS25 Last Chance

Creating a sort of file explorer layout in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 2.2k 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.
  • J Offline
    J Offline
    johnratius
    wrote on 22 Sept 2020, 15:23 last edited by
    #1

    I did some research to find the best widget for creating a sort of table. I concluded that a table widget would be best but after using it a bit, it appears that's not going to work.

    I essentially want to create this:
    alt text
    Each entry will be a row, and they can be sorted by Name, Date, Type, etc...
    So far, a Table is not working because I don't want to select everything in a grid. It should stay as a row.
    Is something like this readily available as a Qt widget, or will I have to create a custom widget?

    1 Reply Last reply
    0
    • J johnratius
      22 Sept 2020, 15:54

      @Christian-Ehrlicher This will work with items other than folders and files? I am creating a database of books with info so it will read book titles and authors.

      Edit: https://doc.qt.io/archives/qt-5.10/modelview.html
      From what I can tell, it is a QTableView I need, but I am unsure how to set it up properly.

      J Offline
      J Offline
      JonB
      wrote on 22 Sept 2020, 16:12 last edited by JonB
      #4

      @johnratius
      Well, that example does use Qt's QFileSystemModel. You will want to replace that with your own model, so there will be some changes. But the item view UI is the right principle.

      EDIT One thing: You said

      I concluded that a table widget would be best but after using it a bit, it appears that's not going to work.

      Actually as a beginner I might have recommended you to a QTableWidget, why did you reject it? It is just a ready-rolled QTableView with a simple, internal database attached. I don't think you have any special requirements? Ah --- are you going to use a proper database for your books? Then it would not be best. But QSqlTableModel + QTableView can be used.

      J 1 Reply Last reply 22 Sept 2020, 16:49
      3
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 22 Sept 2020, 15:48 last edited by
        #2

        See https://doc.qt.io/qt-5/qtwidgets-itemviews-dirview-example.html

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

        1 Reply Last reply
        3
        • J Offline
          J Offline
          johnratius
          wrote on 22 Sept 2020, 15:54 last edited by johnratius
          #3

          @Christian-Ehrlicher This will work with items other than folders and files? I am creating a database of books with info so it will read book titles and authors.

          Edit: https://doc.qt.io/archives/qt-5.10/modelview.html
          From what I can tell, it is a QTableView I need, but I am unsure how to set it up properly.

          J 1 Reply Last reply 22 Sept 2020, 16:12
          0
          • J johnratius
            22 Sept 2020, 15:54

            @Christian-Ehrlicher This will work with items other than folders and files? I am creating a database of books with info so it will read book titles and authors.

            Edit: https://doc.qt.io/archives/qt-5.10/modelview.html
            From what I can tell, it is a QTableView I need, but I am unsure how to set it up properly.

            J Offline
            J Offline
            JonB
            wrote on 22 Sept 2020, 16:12 last edited by JonB
            #4

            @johnratius
            Well, that example does use Qt's QFileSystemModel. You will want to replace that with your own model, so there will be some changes. But the item view UI is the right principle.

            EDIT One thing: You said

            I concluded that a table widget would be best but after using it a bit, it appears that's not going to work.

            Actually as a beginner I might have recommended you to a QTableWidget, why did you reject it? It is just a ready-rolled QTableView with a simple, internal database attached. I don't think you have any special requirements? Ah --- are you going to use a proper database for your books? Then it would not be best. But QSqlTableModel + QTableView can be used.

            J 1 Reply Last reply 22 Sept 2020, 16:49
            3
            • J JonB
              22 Sept 2020, 16:12

              @johnratius
              Well, that example does use Qt's QFileSystemModel. You will want to replace that with your own model, so there will be some changes. But the item view UI is the right principle.

              EDIT One thing: You said

              I concluded that a table widget would be best but after using it a bit, it appears that's not going to work.

              Actually as a beginner I might have recommended you to a QTableWidget, why did you reject it? It is just a ready-rolled QTableView with a simple, internal database attached. I don't think you have any special requirements? Ah --- are you going to use a proper database for your books? Then it would not be best. But QSqlTableModel + QTableView can be used.

              J Offline
              J Offline
              johnratius
              wrote on 22 Sept 2020, 16:49 last edited by johnratius
              #5

              @JonB Ah did not know about SQTable. I will take a look into that, thanks!

              J 1 Reply Last reply 22 Sept 2020, 17:07
              0
              • J johnratius
                22 Sept 2020, 16:49

                @JonB Ah did not know about SQTable. I will take a look into that, thanks!

                J Offline
                J Offline
                JonB
                wrote on 22 Sept 2020, 17:07 last edited by JonB
                #6

                @johnratius
                If you are going to use a SQL database (can even be file-based SQLite), then see https://doc.qt.io/qt-5/sql-presenting.html and the example at https://doc.qt.io/qt-5/qtsql-tablemodel-example.html, for QSqlTableModel + QTableView You can ignore the "editing" stuff if you just want to display the books table. In the first link they mention how you can disable editing on the table view, and then don't worry about the editing/modifying methods.

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  johnratius
                  wrote on 22 Sept 2020, 17:10 last edited by
                  #7

                  @JonB Thanks! In the future I will add some sort of editing feature, but for now it will just be viewing.

                  1 Reply Last reply
                  0

                  7/7

                  22 Sept 2020, 17:10

                  • Login

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