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. QListView with rows containing multiple fields?
Forum Updated to NodeBB v4.3 + New Features

QListView with rows containing multiple fields?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 7.0k 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.
  • W Offline
    W Offline
    whichpaul
    wrote on last edited by
    #1

    This might be a routine task for someone, but I've hit a brick wall reading the documentation.

    I'm looking to present something like a QListView but with each row containing more than one editable value.

    For example, say I want to show a person's name, age and phone number in one row, as I might with a table but in the styling and functionality of a list. If I were to click on the name field, that field would become editable, then if I were to click on the age field it would become editable and the name field displayed as normal, an so on.

    Unedited the list may look like this (text version):


    | John Smith 21 025555555 |
    | Mary Smith 32 075555555 |

    etc..

    But whilst editing the name in the first row might look like this ... (my crude impression of a text edit box)


    | John Smi ... 21 025555555 |
    | Mary Smith 32 075555555 |

    Each row would be populated with a consistent arrangement of text boxes, spinboxes and other standard widget representing some sort of basic data model.

    I know a table view with delegates will do this sort of thing, but I specifically need the appearance and functionality of a list view for this task.

    Any suggestions, or even better, examples?

    Thanks in advance.

    Paul Swanson

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Use either a QTableView or QTreeView and set the properties of the view so as to make it look like a list view. It is not particularly difficult to do. From memory most can be done from within Qt Designer.

      Good luck.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        I would advice against using a QTreeView if you don't need tree capabilities. It's layout code is more complex than that of QTableView, so it will be more resource intensive. You can make a QTableView look exactly like a QListView with a few lines of code and/or some designer property setting.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          True but for only a few items the difference is not noticeable. It depends upon the use case the OP has.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            Of course. But I am used to work with large sets ;-)

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #6

              No need to boast :-D

              Us mere mortals have to make do with smaller portions ;-)

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • D Offline
                D Offline
                durgeshK
                wrote on last edited by
                #7

                You can also try this, This is just a workaround, i tried something like this in VB6.0 sometime back :)

                Make a custom widget and place all the editables widget on it and arrange it, so that it looks like a row you need.

                Now you can use a QScrollArea as parent of the above created widget. Create the widgets dynamically and arrange them in the QScrollArea.

                But you may face problem if the number of rows will exceed a certain limit.

                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