Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED] Select all records in a tableview

    General and Desktop
    2
    6
    1380
    Loading More Posts
    • 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
      sharon_obl82 last edited by

      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 Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

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

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

        1 Reply Last reply Reply Quote 0
        • S
          sharon_obl82 last edited by

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

          1 Reply Last reply Reply Quote 0
          • dheerendra
            dheerendra Qt Champions 2022 last edited by

            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 Reply Quote 0
            • S
              sharon_obl82 last edited by

              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 Reply Quote 0
              • dheerendra
                dheerendra Qt Champions 2022 last edited by

                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 Reply Quote 0
                • First post
                  Last post