Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7512409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:51:37+00:00 2026-05-29T23:51:37+00:00

im doing simple pagination with QSqlQueryModel select from limit query’s every thing is working

  • 0

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();
}

UPDATE:
i even try to call const function that do the calculate , but still i have compilation error on the new const function :
error C2166: l-value specifies const object

int PlayListSqlModel::calculateVerticalHeader()  const 
{
    int returnHeaderCount = m_iHeaderCount;
    m_iHeaderCount++;
    return returnHeaderCount;

}


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

    if(orientation == Qt::Vertical && role == Qt::DisplayRole)
    {

        return calculateVerticalHeader();
    }
    if (role == Qt::DisplayRole)
    {

        if (orientation == Qt::Horizontal) {
            switch (section)
            {
            case 0:
                return QString("Clip");
            case 1:
                return QString("From");
            case 2:
                return QString("Created Time");
            case 3:
                return QString("Rating");
            case 4:
                return QString("Feed");
            case 5:
                return QString("Double click to watch");
            }
        }
    }
    return QVariant();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:51:39+00:00Added an answer on May 29, 2026 at 11:51 pm

    As long as you have an accessible member variable containing the current page you could simply multiply it with the number of rows per page + row.

      if(orientation == Qt::Vertical && role == Qt::DisplayRole)
        {
    
            return QString("%1").arg(m_currentPage*m_rowsPerPage+section);
        }
    

    But as Alxx said, you thinking that you can’t do any calculations is probably because you fail to call non const methods that return the variables i used in the example above, right?

    Update
    The reason you get error C2166: l-value specifies const object is because you try to increment the class variable: m_iHeaderCount++ which is not allowed within a const declarated method. You may modify local variables within the headerData method but not class variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am now doing a simple thing, I am going to read from a
When doing simple maths using now() ... mysql> select cdrstatuschangets from cdrs where (
I'm doing simple tests on all files in directory. But from some reason, sometimes,
I'm working on returning a recordset from SQL Server 2008 to do some pagination.
It's very convenient to have R scripts for doing simple plots from the command
I'm using Grails 1.3.7 and MSSQL Server 2008. Doing simple query through both dynamic
I am doing simple (for now) application to draw on canvas. I can draw
I'm doing simple string input parsing and I am in need of a string
I am doing simple forms authentication for a small ASP.NET (3.5, C#) application and
I've been doing simple multi-threading in VB.NET for a while, and have just gotten

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.