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

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 last edited by amarism
    #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

    JonBJ 1 Reply Last reply
    0
    • A amarism

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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
      1
      • JonBJ JonB

        @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 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

        • Login

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