Deleting "created" pushbuttons in runtime.
Unsolved
General and Desktop
-
for(int i=0; i<row; i++) { for(int j=0; j<column; j++) { view[k] = new QGraphicsView(this->centralWidget());//this->centralWidget _instance = new VlcInstance(VlcCommon::args(), this); _player[k] = new VlcMediaPlayer(_instance); video[k] = new VlcWidgetVideo(this->centralWidget()); //cntralWidget in bracket view[k]->setViewport(video[k]); _player[k]->setVideoWidget(video[k]); _equalizerDialog->setMediaPlayer(_player[k]); p1[k]=new QPushButton("pushbutton"); p2[k]=new QPushButton("pushbutton"); label[k]=new QLabel("Mitesh"); layout1[k]=new QHBoxLayout; layout1[k]->addWidget(label[k]); layout1[k]->addWidget(p1[k]); layout1[k]->addWidget(p2[k]); layout[k]=new QVBoxLayout; layout[k]->addLayout(layout1[k]); layout[k]->addWidget(view[k]); switch(flag1) { case 0: gridLayout->addLayout(layout[k],i,j,1,1); break; /* more code here */ } } }
As shown in code I have created p1[k] , p2[k], and label[k] widgets.
But in some cases I dont need them. How to remove extra widgets. -
@mit_cruze
Yes, you cannot hide a layout.
You must hide the unused buttons.If you decide to really remove them, there is ONLY one way and its via
takeAt
http://doc.qt.io/qt-5/qlayout.html#takeAtThat give you back your button so you own it again. else layout still owns it and u are not allowed to delete it.
-
@mrjj said in Deleting "created" pushbuttons in runtime.:
Yes, you cannot hide a layout.
But the layouts parent widget though. (
QLayout::parentWidget()
)
Which is the widget it has to been installed on when the layout is visible.