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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:58:32+00:00 2026-06-13T03:58:32+00:00

My aim is to create an array of command link buttons dynamically on clicking

  • 0

My aim is to create an array of command link buttons dynamically on clicking a push button in and then display them all inside a vertical layout inside a QscrollArea. I get the data for the buttons from a database. For this I created a slot for the button and wrote the following code inside the slot function.

QCommandLinkButton *slotButtons[10];
for(int i=0; slotQuery.next(); i++)
{
    slotButtons[i] = new QCommandLinkButton;
    slotButtons[i]->setText(slotQuery.value(0).toString());
    slotButtons[i]->setDescription(slotQuery.value(1).toString());


    ui->scrollAreaSlots->layout()->addWidget(slotButtons[i]);
    ui->scrollAreaSlots->show();
    slotButtons[i]->show();


} 

This compiles without errors but the buttons are not visible, even after calling show.
Could anyone tell me where I’m going wrong?

Update: If i remove all the “[i]”s and comment the loop; basically creating just a single command link button, it works perfectly. But it doesn’t work for the loop. Is everything right with my looping?

  • 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-13T03:58:33+00:00Added an answer on June 13, 2026 at 3:58 am

    The QScrollArea has one child widget which can contain other widgets.

    When a QScrollArea widget is created with Qt Creator’s UI designer, Qt Creator creates automatically a widget named scrollAreaWidgetContents. Buttons are then added to that widget’s layout, which is not created automatically. The layout is created in the following code which also add the buttons:

    QCommandLinkButton *slotButtons[10];
    QVBoxLayout* layout = new QVBoxLayout(ui->scrollAreaWidgetContents);
    for(int i=0; slotQuery.next(); i++)
    {
        slotButtons[i] = new QCommandLinkButton;
        slotButtons[i]->setText(slotQuery.value(0).toString());
        slotButtons[i]->setDescription(slotQuery.value(1).toString());
        ui->scrollAreaWidgetContents->layout()->addWidget(slotButtons[i]);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying create an array of variables in different types. My aim is
My aim is to create a map function like this map = function ()
My aim is to create a status bar application which will draw drop down
My aim is to create a navigation menu using jquery. when the user rollover
I'm working on a simple crawler in Python. The aim is to create a
Is it possible to create types like e.g. String(20) in scala? The aim would
Aim : To convert a integer value first to hexstring and then to byte[].
What I can do: I aim to create a view where a User Control
My aim is to create an application whereby a user can drag a label
My aim is to create nested resources via one REST request. The REST requests

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.