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. can i donot setCentralWidget in QMainWindow?

can i donot setCentralWidget in QMainWindow?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 756 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by
    #1

    can i donot setCentralWidget in QMainWindow?
    and then i just add some dockWidget there. but without a CentralWidget.
    is it safe to donnot set it?

    jsulmJ 1 Reply Last reply
    0
    • O opengpu

      can i donot setCentralWidget in QMainWindow?
      and then i just add some dockWidget there. but without a CentralWidget.
      is it safe to donnot set it?

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

      @opengpu Why?

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

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Well docs says
        "Note: Creating a main window without a central widget is not supported. You must have a central widget even if it is just a placeholder."

        1 Reply Last reply
        2
        • O Offline
          O Offline
          opengpu
          wrote on last edited by
          #4

          @mrjj said in can i donot setCentralWidget in QMainWindow?:

          placeholder

          placeholder? simply setCentralWIdget(new QWidget())?

          mrjjM 1 Reply Last reply
          0
          • O opengpu

            @mrjj said in can i donot setCentralWidget in QMainWindow?:

            placeholder

            placeholder? simply setCentralWIdget(new QWidget())?

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

            @opengpu
            yes.

            O 1 Reply Last reply
            1
            • O Offline
              O Offline
              opengpu
              wrote on last edited by opengpu
              #6
              QWidget* pCentralWidget = new QWidget(this);
              //pCentralWidget->setVisible(false); //which is better?
              //pCentralWidget->setFixedSize(QSize(0,0)); //which is better?
              setCentralWidget(pCentralWidget);
              
              1 Reply Last reply
              0
              • mrjjM mrjj

                @opengpu
                yes.

                O Offline
                O Offline
                opengpu
                wrote on last edited by
                #7

                @mrjj //which is better?

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  well what do you try to do ?
                  i would say setVisible(false); if you try to hide it.

                  Normally all other widgets live in CentralWidget
                  so its odd if you want to hide it.

                  O 2 Replies Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    well what do you try to do ?
                    i would say setVisible(false); if you try to hide it.

                    Normally all other widgets live in CentralWidget
                    so its odd if you want to hide it.

                    O Offline
                    O Offline
                    opengpu
                    wrote on last edited by
                    #9

                    @mrjj i want all the Widgets are dockwidget

                    1 Reply Last reply
                    0
                    • enjoysmathE Offline
                      enjoysmathE Offline
                      enjoysmath
                      wrote on last edited by
                      #10

                      I would support a central widget by implementing drag-n-drop of docks into the center and vise versa.

                      https://github.com/enjoysmath
                      https://math.stackexchange.com/users/26327/exercisingmathematician

                      1 Reply Last reply
                      0
                      • mrjjM mrjj

                        Hi
                        well what do you try to do ?
                        i would say setVisible(false); if you try to hide it.

                        Normally all other widgets live in CentralWidget
                        so its odd if you want to hide it.

                        O Offline
                        O Offline
                        opengpu
                        wrote on last edited by
                        #11

                        @mrjj said in can i donot setCentralWidget in QMainWindow?:

                        Normally all other widgets live in CentralWidget

                        Normally all other widgets live in CentralWidget? but i think the DockWidget is in the MainWindow which is their parent.

                        mrjjM 1 Reply Last reply
                        0
                        • O opengpu

                          @mrjj said in can i donot setCentralWidget in QMainWindow?:

                          Normally all other widgets live in CentralWidget

                          Normally all other widgets live in CentralWidget? but i think the DockWidget is in the MainWindow which is their parent.

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

                          @opengpu
                          Hi
                          Yes dockwidgets do live outside central. (around it)
                          I mean other widgets. But if you dont need it, i guess only docks are fine :)

                          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