Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:44:31+00:00 2026-06-16T14:44:31+00:00

I have problem getting selected rows from QTableWidget. I have table like this: [id]

  • 0

I have problem getting selected rows from QTableWidget. I have table like this:

[id]  [ key ]
 0     test
 1     pass

I want to get every row’s key values. I tried QTableWidget->selectedIndexes(); but it says it’s protected and I can’t access that. When I tried QTableWidget->SelectionModel->selectedIndexes, I don’t know how to loop through list and get the key values. Do anyone know better way how can I do it?
Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:44:32+00:00Added an answer on June 16, 2026 at 2:44 pm

    I’m assuming that you set the selection behavior of your table widget to select rows.

    You can always access the so-called “selection model” of any item view/widget. QTableWidget inherits from QAbstractItemView, which gives you access to this special model. This model can tell you the selected rows as a list of QModelIndex, which can then tell you the row. Once you’ve got them, you can access the table content, in your case the text in the column with index 1 (key column).

    static const KEY_COLUMN = 1;
    
    QList<QString> selectedKeys;
    QItemSelectionModel *selectionModel = ui->tableWidget->selectionModel();
    foreach(QModelIndex index, selectionModel->selectedRows())
        selectedIDs << ui->tableWidget->item(index->row(), KEY_COLUMN)->text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with getting text from selected position of JComboBox. I tried
I have this problem getting my newly created php project on Netbeans work on
I have a problem with getting jquery to retrieve results from a WCF service.
I have problem with getting values from select option when use JQuery UI $('#id').combobox().
I have a problem with getting something from the previous activity of my application.
THIS IS THE CONTINUATION OF MY QUESTION: I have a problem with getting something
hi i have problem with enum types I am doing like this.... namspace XXXXXXxx
I have a problem with getting selected objectfrom my list. I bind collection of
I have a problem with getting the pixels from an image. I load a
I just started a graphical C++ course and I have problem getting an overview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.