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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:11:17+00:00 2026-05-31T22:11:17+00:00

I create a QRadioButton array and tried to init it with six radioButtons. At

  • 0

I create a QRadioButton array and tried to init it with six radioButtons. At the moment when i populate array with object i do not receive any warnings or errors. But when i try to see if radio button is check i get crash for all radio button , but not for first item from array.
Here is the code :

// rd is declared in .h as  QRadioButton *rd[6];

   for (int c=0,c<6,c++) {
           rd[c] = new QRadioButton("name");
           verticalBox->addWidget(rd[c]);  // it's a layout
   }

Then make cheking :

  if (rd[0]->isChecked() == true)
        qDebug()<<"checked";
    else if (rd[1]->isChecked() == true)
        qDebug()<<"checked";
    else if (rd[2]->isChecked() == true)
        qDebug()<<"checked";
   else if (rd[3]->isChecked() == true)
        qDebug()<<"checked";
    else if (rd[4]->isChecked() == true)
        qDebug()<<"checked";
    else if (rd[5]->isChecked() == true)
        qDebug()<<"checked";
  • 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-05-31T22:11:18+00:00Added an answer on May 31, 2026 at 10:11 pm

    Don’t know exactly what is causing your crash, but I suggest you to leverage C++ features and Qt containers instead of manipulating C style arrays. Try this:

    // rd is declared in .h as  QList<QRadioButton*> rd;
    for (int i=0; i<6; ++i) {
      QRadioButton * radio_btn = new QRadioButton("name");
      rd << radio_btn; // append radio button to the list
      verticalBox->addWidget(radio_btn);
    }
    

    The rest of your code should execute fine

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

Sidebar

Related Questions

create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
create table snippet( id int not null auto_increment, primary key(id), idlanguage int not null,
Create Table: CREATE TABLE `category` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255)
I am tring to create a simple UserControl that contains a set of RadioButtons
I am trying to create a traffic light for class. We are not allowed
Tried to create this Extension method. Works except that the helper is rendering text,
PS: the reference link www.­androidpeople.­com/­android-­custom-­listview-­tutorial-­part-­1 is not available. Dears, I am trying to create
I am not matlab programmer but I need to create an interface using matlab!
I have six radio buttons in XAML, and I would like to create two
I need create a list of RadioButtons, but if I try to do it

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.