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 set Qt::Vertical headerData of QSqlQueryModel increasing numbers when doing pagination
Qt 6.11 is out! See what's new in the release blog

How to set Qt::Vertical headerData of QSqlQueryModel increasing numbers when doing pagination

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

    im doing simple pagination with QSqlQueryModel select from limit query's
    every thing is working fine . but. now i like to reflect the Vertical headerData of the QTableView .
    im implementing the headerData , beacose it is const function i can't do any calculation inside it . so i have problem to calculate the right numbers in the Vertical headers. for example is im getting the rows from 20 to 30 .
    i like the Vertical header show the numbers 20 to 30 . and so on ...
    this is how i implement the headerData

    @QVariant PlayListSqlModel::headerData(int section, Qt::Orientation orientation, int role) const
    {

    if(orientation == Qt::Vertical && role == Qt::DisplayRole)
    {
    
        return section;
    }
    if (role == Qt::DisplayRole)
    {
    
        if (orientation == Qt::Horizontal) {
            switch (section)
            {
            case 0:
                return QString("name");
            case 1:
                return QString("From");
            case 2:
                return QString("Created Time");
            case 3:
                return QString("last name");
            case 4:
    
            }
        }
    }
    return QVariant();
    

    }@

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      wat error u are getting?

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        error C2166: l-value specifies const object

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          "case 4" does not have a statement. You must add a regular statement/return statement or just break.

          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