Please nominate your Qt Champions for 2021!

QWidget unmovable

  • Hello,

    I've created my own class that inherits from QWidget. This widget is centered on my QMainWindow and countains several widget like some QSpinBox and QLineEdit.

    The problem is that when a QSpinBox or a QLineEdit at the bottom of the widget is right-clicked, the widget automaticly moves up to make the right-clicked menu visible on the mainWindow.

    I would like to know if there's a way to forbidde that either by making the widget unmovable or defining some properties for this menu that would avoid that move.


  • Hi,

    I am not sure that I got correctly your idea but if the instance of your own class that inherits from QWidget is not part of the mainWindow you can consider to make it "modal": This way you will prevent other windows from getting input.


  • In think you got it but the QWidget is not a separate window, its parent is the QMainWibnow.
    Your solution would work but it's to different from what I want to do.

  • That seems very odd that when you right click on a widget that it would move. Do you have any code we could look at?

  • In fact, my code is split in lots of files bso it won't be easy to show you.
    But I've made some deeper tests and the problem might be more complex indeed.

    In fact I think this is because I'm using a QGraphicsView with a scene. I put QLineEdit and Spinbox in it and when the they are right clicked the menu does everything possible not to get out of the QGraphicsView.

    I'm not sure I'm really clear sorry.

Log in to reply