What determines initial position *on screen* of a widget?



  • Sorry if I overlooked any prior answers to this question.

    I have an app with significant number of widgets with a rather complex tree of heritages relative to each other and the main app. Quite often, I need to post an informational message or query for input - this is generally done with a QMessageBox. I haven't figured out how to control the position on screen of where the QMessageBox appears. Ideally, it would be co-located with whatever widget posts it. At present, the QMessageBox seems to appear in locations that have nothing to do with what's going on in the app.

    I know how to ask for the position of any widget, but only relative to its parent widget. I know how to set the position of the QMessageBox, but only an absolute position on screen. From what I've figured out so far, I could figure this out by working back through the widget tree and keeping track of each widget relative to its parent, until I finally bump into a main application widget, at which time I could calculate where on screen to pop up the widget.

    Surely there's a smarter way than that. What have I missed?



  • mapToGlobal()
    seems what you looking for.



  • Perfect - worked like a charm!


Log in to reply
 

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