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

  • Home
  • SEARCH
  • 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 7556131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:47:29+00:00 2026-05-30T11:47:29+00:00

In Qt Designer I’m creating multiple labels (for instance): my_label1 my_label2 my_label3 … my_label

  • 0

In Qt Designer I’m creating multiple labels (for instance):

my_label1
my_label2
my_label3
...
my_label n

Then if I want to hide them I do this:

ui->my_label1->hide();
ui->my_label2->hide();
ui->my_label3->hide();
...
ui->my_labeln->hide();

However I would like to define the labels like

my_label[n]

So then I would be able to do this:

for(i=0;i<n;i++)
    {
    ui->my_label[n]->hide();
    }

I read that I can define the widget like:

QLabel* my_label[5];

but is there any way to do the same from Qt Designer?

Thanks in advance!

  • 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-30T11:47:30+00:00Added an answer on May 30, 2026 at 11:47 am

    Finally I decided to do direct assignment:

    QLabel* my_label_array[5];
    my_label_array[0] = ui->my_label1;
    my_label_array[1] = ui->my_label2;
    my_label_array[2] = ui->my_label3;
    my_label_array[3] = ui->my_label4;
    my_label_array[4] = ui->my_label5;
    

    Then I can do for instance:

    for(idx=0;idx<6;idx++) my_label_array[idx]->show();
    for(idx=0;idx<6;idx++) my_label_array[idx]->hide();
    for(idx=0;idx<6;idx++) my_label_array[idx]->setEnabled(1);
    for(idx=0;idx<6;idx++) my_label_array[idx]->setDisabled(1);
    etc...
    

    Then I was able to perform iterations. I believe is not the cleanest way to do it but given my basic knowledge of Qt is ok for me.

    Thank you very much for your answers and your support! This is a great site with great people.

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

Sidebar

Related Questions

In SharePoint Designer I use some lists as sources and then link them together
Settings.settings generates Settings.Designer.cs which presumably generates app.config which then is copied to output directory
The designer want to make the company name in blue, but the company name
My designer has made a few animations for a flash game and I want
A designer is making some Windows icons (.ico) for us and I want to
Question about the WinForms designer and how to customize behavior. What I've seen multiple
A designer coded an html template using CSS best practices. I want to use
my designer passed me a look that I would love to be able to
based on .designer.cs, i infer that the menu's arrangement is based on the order
I would like the designer to be able to open the same solution file

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.