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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:58:57+00:00 2026-05-30T17:58:57+00:00

I am adding three tables dynamically in widget containing table widget and labels, but

  • 0

I am adding three tables dynamically in widget containing table widget and labels, but nothing shows on screen, I have tried to do it with vertical layout but it does not expand if i add a new row, so not scrolling.
Is there any other way to get all three tables on a same page with scrolling.

QScrollArea *m_scrollArea =ui->scrollArea_Stats;
m_scrollArea->setWidgetResizable(true);
QWidget *area = new QWidget;
QVBoxLayout *vlay = new QVBoxLayout(m_scrollArea);
area->setLayout(vlay);
StatsWidget *objStatsWidget;

for(int i=0;i<2;i++)
{
    objStatsWidget=new StatsWidget(ui->scrollArea_Stats);
    vlay->addWidget(objStatsWidget);
}

 m_scrollArea->setWidget(area);

here StatsWidget is my custom widget containing 2 lables at top and a table widget
I am adding three tables dynamically but page is not scrolling, vlay is not showing all tables it is just showing what it can show in a page without scrolling.

  • 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-30T17:58:59+00:00Added an answer on May 30, 2026 at 5:58 pm

    try rewrite the code as this:

    m_scrollArea->setWidgetResizable(true);
    QVBoxLayout *vlay = new QVBoxLayout;
    StatsWidget *objStatsWidget;
    
    for(int i=0;i<2;i++)
    {
        objStatsWidget=new StatsWidget(ui->scrollArea_Stats);
        vlay->addWidget(objStatsWidget);
    }
     QWidget *area = new QWidget(m_scrollArea);
     area->setLayout(vlay);
     m_scrollArea->setWidget(area);
    

    EDIT: i made something like what you are trying to do some time ago..
    so: create a custom QWidget with a QVBoxLayout as member.let’s call this object “widgetList”. then reimplement all method that you need, as addWidget, takeAt etc.. using your layout as a list
    finally set widgetList as widget for your scroll area..
    let me know..

    I made all this because QWidgetList was not enough easy to use and i needed something else that i have omitted here..

    I found my piece of code:

    class WidgetList : public QWidget
    {
        Q_OBJECT
    
    public:
        WidgetList(QWidget *parent = 0);
        ~WidgetList();
    
        void addWidget(QWidget*);
        void removeWidget(QWidget*);
    
        QList<QWidget*> getListWidget() const;
        QWidget* takeAt(int) const;
        int count() const;
    
    private:
        QVBoxLayout* layout_;
    };
    

    .cpp

    WidgetList::WidgetList(QWidget *parent)
        : /**/QWidget(parent)
          /**/,layout_(new QVBoxLayout(this))
    {
        this->setLayout(layout_);
    }
    
    
    void WidgetList::removeWidget(QWidget* widget)
    {
        layout_->removeWidget(widget);
    }
    
    void WidgetList::addWidget(QWidget* widget)
    {
        layout_->addWidget(widget);
    }
    
    QWidget* WidgetList::takeAt(int index) const
    {
        return layout_->takeAt(index)->widget();
    }
    
    int WidgetList::count() const
    {
        return layout_->count();
    }
    

    this will be your new Widget with layout where to insert your custom widget..
    then i put widgetList as widget of QScrollArea:

    QScrollArea* scrollArea = new QScrollArea;
    widgetList* list = new widgetList(scrollArea);
    scrollArea->setWidget(list);
    

    everything works for me..

    EDIT 2: i post my main that works good with my previous code:

    QScrollArea* scroll = new QScrollArea;
    WidgetList* w = new WidgetList(scroll);
    QLabel * label = new QLabel("Label1");
    QLabel* label2 = new QLabel("label2");
    QTableWidget* table = new QTableWidget(10,10);
    
    w->addWidget(label);
    w->addWidget(label2);
    w->addWidget(table);
    
    scroll->setWidget(w);
    scroll->setWidgetResizable(true);
    scroll->show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in which I am adding some rows dynamically and in
I have a fairly large html table and I'm adding a new rows dynamically
I have a HTML table where I am dynamically adding and hiding rows and
I have a common database joining situation involving three tables. One table, A, is
I have a table called newDataTable where I am adding new rows dynamically with
So... assuming i have a database with three tables: Table clients Table data and
I have a .aspx page that loads three separate .ascx controls to represent adding,
I am dynamically adding input elements to a table with the id of inputDataElements
Suppose I have the following three tables expressing a relationship where posts are given
I have an activity that shows customer information. All the controls are drawn dynamically

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.