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 7710151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:02:52+00:00 2026-06-01T01:02:52+00:00

I would like to create a window in Qt that contains a QTableWidget composed

  • 0

I would like to create a window in Qt that contains a QTableWidget composed of 4 columns, one of text and the last 3 are QRadioButtons.
I was able to create this:

MainWindow interface

However, I am unable to group the QRadioButtons by row. Indeed, with this current UI, I can only select ONE radio from the 30 displayed, instead of one per row.
Here’s my code:

// 1st col stretchable, other 3 fixed width
QHeaderView *header = ui->tableWidget->horizontalHeader();
header->setResizeMode(QHeaderView::Stretch);
header->setResizeMode(1, QHeaderView::Interactive);
header->setResizeMode(2, QHeaderView::Interactive);
header->setResizeMode(3, QHeaderView::Interactive);

// Can't select lines
ui->tableWidget->setSelectionMode(QAbstractItemView::NoSelection);

// Test: fill the list
ui->tableWidget->setRowCount(10);
QLabel *nom;
QRadioButton *radio1, *radio2, *radio3;
for (int i = 0; i < 10; i++) {
    nom = new QLabel();
    nom->setText(QString("test")+QString::number(i));
    ui->tableWidget->setCellWidget(i, 0, nom);

    radio1 = new QRadioButton();
    radio2 = new QRadioButton();
    radio3 = new QRadioButton();
    ui->tableWidget->setCellWidget(i, 1, radio1);
    ui->tableWidget->setCellWidget(i, 2, radio2);
    ui->tableWidget->setCellWidget(i, 3, radio3);
}

How can I do this?

  • 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-01T01:02:54+00:00Added an answer on June 1, 2026 at 1:02 am

    The default behavior of the QRadioButton is to be exclusive with all the other buttons under that same parent. In this case, they are all being parented to the tableWidget once you set them in their cells.

    What you should do is at the end of every loop, create a new QButtonGroup, set one of the buttons to checked, and then add all 3 to the button group. Now each of those rows will be exclusive only within the QButtonGroup you created for each row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For Android GUI: I would like to create a window that I can pull
I would like to create a small Windows Messenger Client that I can trigger
i'd like to create a windows service that would be accessible via WCF from
I would like to create a window with a progressbar which shows the current
I would like to create a javascript modal pop up window to get some
I would like create my own collection that has all the attributes of python
I would like create a web service in ASP.Net 2.0 that will supports JSON.
I would like to create application with ribbon interface that looks and behaves like
I would like to open an Ext.Window in ExtJS , that will open an
I have a static class which contains a RoutedUICommand that I would like to

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.