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]Extracting data to display in QListView

[Solved]Extracting data to display in QListView

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.2k 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
    weblife
    wrote on last edited by
    #1

    I want to make my QListView bind to my QSqlQueryModel. So far the below code works but will only display the first column data of each row(I believe, or it is counting each row that exist as 1,2,3...). How can I make it so I can display say column 2 that holds a column name reference (ie: The 2,3,4 columns that will produce "Marry Joe Smith").

    @void ListUI::addItem(QSqlQueryModel *model){
    theList->setModel(model);
    }@

    Output:
    1
    2
    3
    4

    Brandon Clark
    www.themindspot.com

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Maybe to simple to say, but a list is a table with only 1 column if you ask me. If you want your model and view to have multiple columns you could use the QTableView.
      Or am I missing a part of the problem?

      Greetz, Jeroen

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        I think you want this:
        @theList->setModelColumn(1);@

        Indexing of columns starts from 0

        1 Reply Last reply
        0
        • W Offline
          W Offline
          weblife
          wrote on last edited by
          #4

          @qxoz thank you. I had not seen that member.

          Brandon Clark
          www.themindspot.com

          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