Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QMainWindow top left position excluding frames and menu bar?
I have a central widget with an opengl viewport. A graphics View.
I have the window and the QMenuBar on it.
I need to position floating buttons over the viewport.
I want to position them relative to the viewport, top left position, 0,0 . But surprissingly 0,0 is over the MenuBar, as if the menu bar was part of the viewport.
button_->move( mainWindow_->centralWidget()->geometry().x(), mainWindow_->centralWidget()->geometry().y() + mainWindow_->menuBar()->height() );
But when i grab the window to demaximize it, the button doesn´t stay in the same position. Sometimes stays a little upper, others, on the left...
I need the 0,0 position ! but it doesn´t work with mainWindow_ , neither with centralWidget()
rcari last edited by
You should take a look at "that":http://qt-project.org/doc/qt-4.8/application-windows.html#window-geometry. Hope this helps!
That doesn´t work. I knew you would probably tell me that :D
Doesn´t work at all. It only talks about the TITLE BAR, no the menu bar.
geometry 0,0 means top left of the MENU BAR.
I finally did it by hand, using by hand values, but this sollution is so bad... i don´t find another way!.
tilsitt last edited by
did you try "mapToGlobal":http://qt-project.org/doc/qt-4.8/qwidget.html#mapToGlobal