Open QMenu to particular side



  • Hi I'm using a QMenu in my QApplication and depending on the position of the QMainWindow the menu items open to the left side or the right side. How can I control to which side the menu items open up when clicking on the menu? Is there a method to control this on the menu? I want that the menu always opens to the left side, never to the right side. Any help is appreciated.



  • No one knows how to do this?


  • Lifetime Qt Champion

    Hi,

    For what you want to do you would probably have to implement a custom QMenu in order to modify the popup handling.

    Out of curiosity, why do you want to do that ?



  • @SGaist My app uses a virtual desktop with two windows, and I want the pop up to only open to the side that resides within the window where the menu resides. Currently the QApp spans across windows, so takes up the full virtual desktop, and then the pop up opens to the side where the second window lies. I want the pop up to be kept on the window where it is opened.


  • Lifetime Qt Champion

    It's a bit clearer. To see how you setup your menus, can you show an image of your application ?



  • I have found the solution btw, if anyone ever gets the same problem. It was quite easy actually:

    setLayoutDirection( Qt::RightToLeft );


Log in to reply