how can i set QDockWidget without close button?
-
hello everyone, i use the QDockWidget widget, but i do not want user to close the QDockWidget, so ,i want to hidden the close button, i have tried :
scenesDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
but it doesn't work.
so i tried:
scenesDock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
but it also doesn't work. the close button is also there.
how can i do that? -
@finyone said in how can i set QDockWidget without close button?:
i want to know how can i hidden the close button?
Removing QDockWidget::DockWidgetClosable I would say:
scenesDock->setFeatures(scenesDock->features() & ~QDockWidget::DockWidgetClosable);
-
@mrjj thanks for your reply, i use OBS studio, that is a soft for live video.
and i use it in windows, the code is
"
ui->setupUi(this);
ui->previewDisabledLabel->setVisible(false);
ui->scenesDock->setFeatures(ui->scenesDock->features() & ~QDockWidget::DockWidgetClosable);
"but run it , i find the close button is also there , Does it need me also set the QDockWidget's setFeatures in GUI designer ?
-
@finyone
Hi that is od as seems fine.
Well anything you setup in Designer is done after
ui->setupUi(this);So i wonder if its due to it already being docked.
Could you try sample ?
and at line 450 in mainwindow.cpp, function void MainWindow::createDockWidget()
void MainWindow::createDockWidget() { CreateDockWidgetDialog dialog(this); if (dialog.exec() == QDialog::Rejected) return; QDockWidget *dw = new QDockWidget; dw->setFeatures(dw->features() & ~QDockWidget::DockWidgetClosable); <<<<< ...
and run then insert one from menu.
and see if it still has close button.
-
scenesDock->setFeatures(QDockWidget::NoDockWidgetFeatures); did the job for me if you still have the problem i believe this will solve the issue