I want to take list widget dynamically and take multiple push button inside listwidget dynamically
-
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 -
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@amarism
You are trying to usesetLayouton a wholeQListWidget. I imagine that is not the usage. You should be creatingQListWidgetItems and thenQListWidget::insertItem()to populate it with items.That's what a
QListWidgetis 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. -
@amarism
You are trying to usesetLayouton a wholeQListWidget. I imagine that is not the usage. You should be creatingQListWidgetItems and thenQListWidget::insertItem()to populate it with items.That's what a
QListWidgetis 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.@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.
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
