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

QTableView Does not work

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 190 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.
  • C Offline
    C Offline
    canrollas
    wrote on last edited by
    #1

    Hi, this is my init. code of the mainwindow constructor. I can not see where I'm doing wrong? There will be empty tableview when I run it.

     QStandardItemModel model(rows, columns);
        for (int row = 0; row < rows; ++row) {
            for (int col = 0; col < columns; ++col) {
                model.setItem(row, col, new QStandardItem(QString("asdasd")));
            }
        }
        qInfo()<<"This is model:"<<model.item(0,0)->text();
        ui->tableView->setModel(&model);
    
        ui->tableView->show();
    
    
    jsulmJ 1 Reply Last reply
    0
    • C canrollas

      Hi, this is my init. code of the mainwindow constructor. I can not see where I'm doing wrong? There will be empty tableview when I run it.

       QStandardItemModel model(rows, columns);
          for (int row = 0; row < rows; ++row) {
              for (int col = 0; col < columns; ++col) {
                  model.setItem(row, col, new QStandardItem(QString("asdasd")));
              }
          }
          qInfo()<<"This is model:"<<model.item(0,0)->text();
          ui->tableView->setModel(&model);
      
          ui->tableView->show();
      
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @canrollas said in QTableView Does not work:

      QStandardItemModel model(rows, columns);

      Your model is a local variable...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • C Offline
        C Offline
        canrollas
        wrote on last edited by
        #3

        @jsulm said in QTableView Does not work:

        Your model is a local variable...

        thank you sir I confused :)

        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