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 data from sqlquery that result 3 columns in a row and show only 1 Colum and use the other columns data
Forum Updated to NodeBB v4.3 + New Features

How to get data from sqlquery that result 3 columns in a row and show only 1 Colum and use the other columns data

Scheduled Pinned Locked Moved General and Desktop
28 Posts 3 Posters 15.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.
  • A Offline
    A Offline
    andre
    wrote on 2 Apr 2012, 12:13 last edited by
    #21

    [quote author="umen242" date="1333367911"]no its the opposite, the data function is in the QSqlQueryModel.
    i dont understand this :
    @"...so you can still query these from the data method of proxy model...."@

    how ? where ?

    do you mean i need to implement the data method of the proxy ?[/quote]
    See the edit to my post above for an example.

    1 Reply Last reply
    0
    • U Offline
      U Offline
      umen242
      wrote on 2 Apr 2012, 12:15 last edited by
      #22

      Thanks very much i will try it now

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 2 Apr 2012, 12:21 last edited by
        #23

        Note that this example does not try to modify any data. It just changes whatever it tells the user of the model is the data in it. Also note that I did not implement setData(). If you need to support setData too (for this role), things will quickly become more complicated...

        1 Reply Last reply
        0
        • U Offline
          U Offline
          umen242
          wrote on 2 Apr 2012, 12:30 last edited by
          #24

          hi i tryed you example , and there is 2 problems and that i dont understand
          first one is that when it is:
          @if (index.column() == 0 && role == Qt::UserRole) {@
          it never enter the if , but when i change it to
          @if (c == 0 && role == Qt::DisplayRole) {@

          it does Enter , but as expected the joined string is displayed in the row displayRole
          how can i put it in the UserRole?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 2 Apr 2012, 12:34 last edited by
            #25

            Of course it is not entered, it is only entered when the UserRole is actually requested. That is how it ends up "in" the display role. The role is only the argument you pass to the data() function. Nothing more, nothing less. The normal delegates don't query for the UserRole (they only need the standard roles).

            1 Reply Last reply
            0
            • U Offline
              U Offline
              umen242
              wrote on 2 Apr 2012, 12:51 last edited by
              #26

              ok so how do i trigger it to be requested ? so i finally could set it

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on 2 Apr 2012, 12:58 last edited by
                #27

                You simply request the data manually, where you need it. I assume you set this dat to the userRole for a reason, right? And that reason is presumably that you need this bit of information somewhere. So, how about actually requesting the data where you need it? It would be as simple as getting the right QModelIndex (that is: an index pointing to your proxy model; your view may supply it), and calling data(Qt::UserRole) on it.

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  umen242
                  wrote on 2 Apr 2012, 13:20 last edited by
                  #28

                  finally !
                  this wasn't trivial at all man . its working thanks to you .
                  thanks!

                  1 Reply Last reply
                  0

                  21/28

                  2 Apr 2012, 12:13

                  • Login

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