Set QWidget to be "unmovable"



  • Hi!

    I'm looking for a way to prevent several QWidgets from beeing moved.
    I got a MainWindow as parent and some QWidgets as Child-Windows which are created in a preset order and size in my MainWindow. Now I want these QWidgets to keep their position in the MainWindow, till the user tells a QWidgets to be movable (e.g. with a QPushButton in MainWindow). So the QWidgets moving behavior could be described as "static" when they are initialized and this "static"-Flag can be triggered. I couldn't figure out a "best practice"-way to to achieve this, since i couldn't find a flag or attribute that would work for me. I came across the possibility to use setWindowFlags(Qt::FramelessWindowHint) for "static" QWidgets and setWindowFlags(Qt::Widget) for "non-static". So I'm actually hiding the QWidgets Titlebar, which would work - BUT I need the Titlebar to show several additional status informations all the time, not only in "non-static" mode.

    I hope u actually got what my problem is and maybe got a solution for me :D



  • Are these QWidgets you are referring to embedded in your QMainWindow or are they separate windows?

    If the former I would call "QWidget::setFixedSize":http://doc.qt.nokia.com/4.7/qwidget.html#setFixedSize on your widgets.



  • These are separate windows. Anyhow I dont see why setting a fixed size for the widgets would help me make me those QWidgets unmovable?



  • I'd take a look into the Widgets > Window Flags Qt example. Or try the cheap solution: when the user orders moving the window, move it back to the original position XD.

    Anyway, good luck!

    PS: also, I think it's possible to avoid movement via OS -Linux, that is-...

    --


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.