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. QWindow and QMenuBar
Forum Updated to NodeBB v4.3 + New Features

QWindow and QMenuBar

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 926 Views 5 Watching
  • 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.
  • JonBJ JonB

    @SPlatten
    For the other part. There is void QLayout::setMenuBar(QWidget *widget)

    Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar.

    So can't you use that to put a QMenuBar on any QWidget. But a QWindow is a native window, not a widget, so not directly on that. Not sure you meant QWindow? You cannot replace a QWindow by a QMainWindow.

    SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #4

    @JonB in my application I presently have one instance of QMainWindow and several instances of QWindow, although I set-up a QMenuBar and added QMenus to it, with QActions, the menu bar is not being displayed.

    Kind Regards,
    Sy

    SGaistS 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @JonB in my application I presently have one instance of QMainWindow and several instances of QWindow, although I set-up a QMenuBar and added QMenus to it, with QActions, the menu bar is not being displayed.

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @SPlatten as @JonB already wrote, a QWindow is not a QWidget hence you can't set a QMenuBar on it.

      How did you implement that in your code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 1 Reply Last reply
      0
      • SGaistS SGaist

        @SPlatten as @JonB already wrote, a QWindow is not a QWidget hence you can't set a QMenuBar on it.

        How did you implement that in your code ?

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #6

        @SGaist , the autocomplete suggests the function setMenuBar and the compiler doesn't complain either, yet its just a QWindow.

        Kind Regards,
        Sy

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • SPlattenS SPlatten

          @SGaist , the autocomplete suggests the function setMenuBar and the compiler doesn't complain either, yet its just a QWindow.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @SPlatten said in QWindow and QMenuBar:

          and the compiler doesn't complain either, yet its just a QWindow.

          Then its not a QWindow ...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • SPlattenS SPlatten

            @SGaist , the autocomplete suggests the function setMenuBar and the compiler doesn't complain either, yet its just a QWindow.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #8

            @SPlatten said in QWindow and QMenuBar:

            and the compiler doesn't complain either, yet its just a QWindow.

            • Show your code rather than asserting this.
            • From List of All Members for QWindow where is the setMenuBar() method?

            It's best to check your facts when (several) others say something cannot be the case. :)

            SPlattenS 1 Reply Last reply
            0
            • JonBJ JonB

              @SPlatten said in QWindow and QMenuBar:

              and the compiler doesn't complain either, yet its just a QWindow.

              • Show your code rather than asserting this.
              • From List of All Members for QWindow where is the setMenuBar() method?

              It's best to check your facts when (several) others say something cannot be the case. :)

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #9

              @JonB, @Christian-Ehrlicher , sorry, you are both correct, in trying to get something going I had messed up and the cast was to QMainWindow.

              Kind Regards,
              Sy

              JonBJ 1 Reply Last reply
              2
              • SPlattenS SPlatten

                @JonB, @Christian-Ehrlicher , sorry, you are both correct, in trying to get something going I had messed up and the cast was to QMainWindow.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #10

                @SPlatten
                :) [And I have appended a friendly smiley to my previous post.]
                A QWindow is a wrapper for a ("low-level") native window on the platform. It is not a QWidget and cannot have something like a menubar or anything like that which a widget can have.

                SPlattenS 1 Reply Last reply
                0
                • JonBJ JonB

                  @SPlatten
                  :) [And I have appended a friendly smiley to my previous post.]
                  A QWindow is a wrapper for a ("low-level") native window on the platform. It is not a QWidget and cannot have something like a menubar or anything like that which a widget can have.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #11

                  @JonB , is there any restriction on the number of instances of QMainWindow, can more than one instance of QMainWindow exist in the same application ?

                  Kind Regards,
                  Sy

                  JonBJ M 2 Replies Last reply
                  0
                  • SPlattenS SPlatten

                    @JonB , is there any restriction on the number of instances of QMainWindow, can more than one instance of QMainWindow exist in the same application ?

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #12

                    @SPlatten
                    I did answer that: there is nothing special about QMainWindow, it is just a widget with the style/behaviour documented at https://doc.qt.io/qt-6/qmainwindow.html#details. You can have a hundred of them if you wish. Though personally I never understand why an application would want more than one main window, but never mind.

                    SPlattenS 1 Reply Last reply
                    1
                    • JonBJ JonB

                      @SPlatten
                      I did answer that: there is nothing special about QMainWindow, it is just a widget with the style/behaviour documented at https://doc.qt.io/qt-6/qmainwindow.html#details. You can have a hundred of them if you wish. Though personally I never understand why an application would want more than one main window, but never mind.

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #13

                      @JonB , the application I'm working on is not a specific application to do a job at all, its an engine that when finished will allow anyone to create a Qt application in JavaScript. The engine provides the Qt functionality, JavaScript and XML are used to create the application and subscriptions.

                      Kind Regards,
                      Sy

                      1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @JonB , is there any restriction on the number of instances of QMainWindow, can more than one instance of QMainWindow exist in the same application ?

                        M Offline
                        M Offline
                        mpergand
                        wrote on last edited by mpergand
                        #14

                        @SPlatten
                        There is an option in QMenuBar that forces the menubar to be displayed in the window on Mac and some linux distros:

                        void setNativeMenuBar(bool nativeMenuBar)

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved