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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k 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
    • S Offline
      S Offline
      shoyeb
      wrote on last edited by
      #2

      wat error u are getting?

      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

      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
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

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

          http://www.catb.org/~esr/faqs/smart-questions.html

          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