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. QFileMenu not appearing at right place when menuFile->show(); called

QFileMenu not appearing at right place when menuFile->show(); called

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 3.3k 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.
  • T Offline
    T Offline
    Tabi
    wrote on last edited by
    #1

    Hi all,
    I am using Qt4.8.3 and in a function I am calling menuFile->show(); to drop the file menu but it is not appearing at right place, it is somewhere near mid of the window. How to drop the filemenu at its right place or it is a bug if with show() it is not appearing at place?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      i guess you mean QMenu right?

      Since QMenu inherits QWidget you need to position it first before showing it. Or even better you use QMenu::exec() and pass it the position where to show it.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tabi
        wrote on last edited by
        #3

        Oh yes it solved the problem :)
        But it should not behave like this. :|

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          what do you mean?
          How should it behave?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tabi
            wrote on last edited by
            #5

            I mean it should appear at right place by default.

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              Yes, but what is the default??
              Even Menu's may be placed where ever you want, so you need to set the position yourself. The same as adding a widget to a layout.
              Your thinking like Win8..............not asking, but just assuming that you want something done automatically......argh...I'm smart, let me decide for myself ;-)
              But this is just sidetracking.

              Greetz, Jeroen

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tabi
                wrote on last edited by
                #7

                I have seen a flag in menu tearOffEnabled. if it is not set then menu should appear at right place. I am just expecting that if it is managed for a normal click why not it is for show().

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  what is the "right place"?
                  A mouse click and the showing of a menu are not directly related to each other. A menu can also be displayed by keyboard for example, whats the correct place in this case?

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Tabi
                    wrote on last edited by
                    #9

                    Just below the menubar and below File title. is not it a default place of a menu?

                    1 Reply Last reply
                    0
                    • JeroentjehomeJ Offline
                      JeroentjehomeJ Offline
                      Jeroentjehome
                      wrote on last edited by
                      #10

                      A menu may also be a context menu when click with right mouse button, so, no there is no default place. I think you are right that normally you expect a menu to appear below the label in the menubar and when in Qt Designer you add the menuBar it will be done so. so if you mean that with 'default' position, ok, But menu's may be placed anywhere on screen.

                      Greetz, Jeroen

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        Tabi
                        wrote on last edited by
                        #11

                        I think in case of context menu we also don't need to care about feed it position. It normally appeared at clicked position default. Yeah in case we want it to appear not on clicked place than we have to care about geometry.

                        1 Reply Last reply
                        0
                        • raven-worxR Offline
                          raven-worxR Offline
                          raven-worx
                          Moderators
                          wrote on last edited by
                          #12

                          but when you use your QMenu as a file menu, meaning you added it to an menu bar of a main window, you don't have to worry about showing and positioning since Qt takes care of it for you.

                          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                          If you have a question please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            Tabi
                            wrote on last edited by
                            #13

                            Thats why I used "default" word. And expecting default behaviour on show().

                            1 Reply Last reply
                            0
                            • JeroentjehomeJ Offline
                              JeroentjehomeJ Offline
                              Jeroentjehome
                              wrote on last edited by
                              #14

                              Sure, but why do you use the show() anyway?
                              That is done in the back by adding your QMenu to the menubar of e.g. a MainWindow. You don't need to call show() on it.
                              Why don't you try to create a new project with a mainwindow form. Add a menu bar and a menu. Then read the ui_mainwindow.h file and all becomes clear what Qt does for you. There is no need to call show() on the menu. All done by the Menu bar class for you.

                              Greetz, Jeroen

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                Tabi
                                wrote on last edited by
                                #15

                                For sake of humanity!
                                Joking. I am preparing a demo run of my GUI if user click on Demo the file menu will drop and so so.. I have set state machine to do this in which I am calling fileMenu's show().

                                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