Question

I am working in c++/ubuntu. I've created a QTable :

  1 | 2
 -------
aaaa|bbbb
cccc|dddd
....|....

I would like to ask how can i select the entire row 2: cccc |dddd.

I did:

QModelIndexList indexes = ui->tableView->selectionModel()->selection().indexes();

    for (int i = 0; i < indexes.count(); ++i)

    {
        QModelIndex index = indexes.at(i);

        if (index.isValid())
        {

          QString s=index.data(Qt::DisplayRole).toString();
          QMessageBox noc;
                  noc.setText(s);
                  noc.exec();
        }


    }

But I see just tje cccc element seleted.

Appreciate. Thx very muxh!

Was it helpful?

Solution

If you're using a Q3Table, theres an enum for handling selections which is set using this function.

If you're using QTableView (which is recommended) there is a similar enum and function to set it.

I hope this helps. As Raiv said in his comment, we can help you more if you clarify your question.

OTHER TIPS

Try to use QTableView::selectedIndexes. This function is for getting selected items.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top