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. [SOLVED] Select all records in a tableview
QtWS25 Last Chance

[SOLVED] Select all records in a tableview

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.7k 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.
  • S Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

    Hi all,

    Does anyone know how can I select/highlight the whole table in qt?
    I've tried using:

    void MainWindow::on_actionSelect_All_triggered()
    {
    ui->tableView->selectAll();

    }

    but it doesn't work.

    Thank you.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Did you check at the property called "cornerButtonEnabled : bool"

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sharon_obl82
        wrote on last edited by
        #3

        hi Dheerendra,
        I added the line ui->tableView->setCornerButtonEnabled(true);
        but it doesn't select all records in the table.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Did you select/click on the button which in top right corner or bottom right corner ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sharon_obl82
            wrote on last edited by
            #5

            I'm trying to put it in a menu 'Select All' so when i click on that menu, all the records on the table will be highlighted

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              See the sample here and selectAll should work. Just check there may issue the way you set it. Just try the following example and it give you inputs to solve your issue.

              @Widget::Widget(QWidget *parent)
              : QWidget(parent)
              {
              view = new QTableView(this);
              QStringListModel *list1 = new QStringListModel;
              QStringList list;
              list<<"10"<<"11"<<"12"<<"13";
              list[0]="100";
              list1->setStringList(list);

              view->setModel(list1);
              //view.setCornerButtonEnabled(true);
              tim = new QTimer;
              tim->setInterval(10000);
              connect(tim,SIGNAL(timeout()),this,SLOT(setall()));
              tim->start();
              

              }

              void Widget::setall(){
              view->selectAll();
              }
              @

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              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