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. how can i set QDockWidget without close button?

how can i set QDockWidget without close button?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 4.2k 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.
  • F Offline
    F Offline
    finyone
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • F finyone

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @finyone Isn't QDockWidget::DockWidgetClosable what you need?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        finyone
        wrote on last edited by
        #3

        thanks for your reply, but QDockWidget::DockWidgetClosable is to show close button.

        i want to know how can i hidden the close button?

        jsulmJ 1 Reply Last reply
        0
        • F finyone

          thanks for your reply, but QDockWidget::DockWidgetClosable is to show close button.

          i want to know how can i hidden the close button?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          F 1 Reply Last reply
          1
          • jsulmJ jsulm

            @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);
            
            F Offline
            F Offline
            finyone
            wrote on last edited by
            #5

            @jsulm said in how can i set QDockWidget without close button?:

            scenesDock->features() & ~QDockWidget::DockWidgetClosable

            thanks,but it doesn't work ,the close button is also there.
            any other ideas?

            mrjjM 1 Reply Last reply
            0
            • F finyone

              @jsulm said in how can i set QDockWidget without close button?:

              scenesDock->features() & ~QDockWidget::DockWidgetClosable

              thanks,but it doesn't work ,the close button is also there.
              any other ideas?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @finyone
              Hi
              What platform are you on?
              It does work on windows.
              alt text

              F 1 Reply Last reply
              0
              • mrjjM mrjj

                @finyone
                Hi
                What platform are you on?
                It does work on windows.
                alt text

                F Offline
                F Offline
                finyone
                wrote on last edited by
                #7

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

                mrjjM 1 Reply Last reply
                0
                • F finyone

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @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 ?
                  alt text

                  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.

                  alt text

                  and see if it still has close button.

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    oktaybagdatli
                    wrote on last edited by
                    #9

                    scenesDock->setFeatures(QDockWidget::NoDockWidgetFeatures); did the job for me if you still have the problem i believe this will solve the issue

                    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