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. I want to print out as many rows as I want in the tableview.
Forum Updated to NodeBB v4.3 + New Features

I want to print out as many rows as I want in the tableview.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 156 Views
  • 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.
  • M Offline
    M Offline
    meria0503
    wrote on last edited by
    #1

    Hello, I'm a beginner Qt developer.

    I expressed the contents of the DB table in tableview. But the code that I've implemented right now is printing all the rows in the table. This is a result I don't want.

    How can I print out the number of rows I want?

    This is what the current code is about.

    QSqlQueryModel *table = new QSqlQueryModel;
    QString sql;
    sql = "select sv,time from hmidata group by sv,time order by time DESC";
    QSqlQuery query;
    if(!query.exec(sql)){
        qDebug () <<"query error:" << query.lastError();
    } else {
        qDebug () <<"query access:" << query.lastQuery();
    }
    table->setQuery(query);
    ui->tableView_gwan->setModel(table);
    ui->tableView_gwan->showRow(10);
    ui->tableView_gwan->setSpan(10,2,10,2);
    ui->tableView_gwan->currentIndex();
    

    Query execution works very well.

    M 1 Reply Last reply
    0
    • M meria0503

      Hello, I'm a beginner Qt developer.

      I expressed the contents of the DB table in tableview. But the code that I've implemented right now is printing all the rows in the table. This is a result I don't want.

      How can I print out the number of rows I want?

      This is what the current code is about.

      QSqlQueryModel *table = new QSqlQueryModel;
      QString sql;
      sql = "select sv,time from hmidata group by sv,time order by time DESC";
      QSqlQuery query;
      if(!query.exec(sql)){
          qDebug () <<"query error:" << query.lastError();
      } else {
          qDebug () <<"query access:" << query.lastQuery();
      }
      table->setQuery(query);
      ui->tableView_gwan->setModel(table);
      ui->tableView_gwan->showRow(10);
      ui->tableView_gwan->setSpan(10,2,10,2);
      ui->tableView_gwan->currentIndex();
      

      Query execution works very well.

      M Offline
      M Offline
      meria0503
      wrote on last edited by
      #2

      When I hung a row limit in the query part, I got the desired result. It's settled.

      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