Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I want to take list widget dynamically and take multiple push button inside listwidget dynamically
Forum Update on Monday, May 27th 2025

I want to take list widget dynamically and take multiple push button inside listwidget dynamically

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amarism
    wrote on 10 Oct 2018, 09:48 last edited by amarism 10 Oct 2018, 09:58
    #1

    I am taking the list widget dynamically as

     QListWidget *widgetOnTheTop = new QListWidgetWidget(this);
          widgetOnTheTop->setGeometry(100,30,100,105);
          widgetOnTheTop->show();
    

    But i am not able to take button inside the list widget . I will try to use this code

     QVBoxLayout *layout=new QVBoxLayout();
          for (int i = 0; i < 4; ++i){
              for(int j=0;j<4;j++){
                QPushButton *button = new QPushButton();
                button->setText(QString::number(i));
                layout->addWidget(button);
                button->show();
              }
          }
        widgetOnTheTop->setLayout(layout);
    

    But nothing will happen.
    Also I want to know is it possible to add button inside the listwidget dynamically.

    Any help is considerable.
    Thank you in advance

    J 1 Reply Last reply 10 Oct 2018, 17:25
    0
    • A amarism
      10 Oct 2018, 09:48

      I am taking the list widget dynamically as

       QListWidget *widgetOnTheTop = new QListWidgetWidget(this);
            widgetOnTheTop->setGeometry(100,30,100,105);
            widgetOnTheTop->show();
      

      But i am not able to take button inside the list widget . I will try to use this code

       QVBoxLayout *layout=new QVBoxLayout();
            for (int i = 0; i < 4; ++i){
                for(int j=0;j<4;j++){
                  QPushButton *button = new QPushButton();
                  button->setText(QString::number(i));
                  layout->addWidget(button);
                  button->show();
                }
            }
          widgetOnTheTop->setLayout(layout);
      

      But nothing will happen.
      Also I want to know is it possible to add button inside the listwidget dynamically.

      Any help is considerable.
      Thank you in advance

      J Offline
      J Offline
      JonB
      wrote on 10 Oct 2018, 17:25 last edited by JonB 10 Oct 2018, 17:26
      #2

      @amarism
      You are trying to use setLayout on a whole QListWidget. I imagine that is not the usage. You should be creating QListWidgetItems and then QListWidget::insertItem() to populate it with items.

      That's what a QListWidget is for. It's a combo/list box of items. It wouldn't surprise me if you cannot put buttons in items, I don't know. I don't understand just what you are trying to achieve. It might help if you explained what you are expecting to achieve/it to look like.

      A 1 Reply Last reply 11 Oct 2018, 06:00
      1
      • J JonB
        10 Oct 2018, 17:25

        @amarism
        You are trying to use setLayout on a whole QListWidget. I imagine that is not the usage. You should be creating QListWidgetItems and then QListWidget::insertItem() to populate it with items.

        That's what a QListWidget is for. It's a combo/list box of items. It wouldn't surprise me if you cannot put buttons in items, I don't know. I don't understand just what you are trying to achieve. It might help if you explained what you are expecting to achieve/it to look like.

        A Offline
        A Offline
        amarism
        wrote on 11 Oct 2018, 06:00 last edited by
        #3

        @JonB I have a comboBox and onclick of combo Box i want to create a dynamic widget were they have multiple buttons.
        This whole work is using for showing the slipt screen of QOpenGLWidget like (1x1,1x2,2x1,4x5..... so on). I am taken the same example from RADint viewer. I am also attaching the image view of what i want to do in my project.

        0_1539237389218_splitsScreen.png

        I want to achieve this type of combo Box .Highlighting the row and column will display the respective screen. as example this image we take highlight 3*4 view my OpenGLWidget is distribute respectively. like

        0_1539237591604_test.png

        1 Reply Last reply
        0

        1/3

        10 Oct 2018, 09:48

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved