[SOLVED] Select all records in a tableview



  • 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.



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



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



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



  • 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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.