Keep widget on top in Qt

qt, qt4, widget

Solution

Use the flag `Qt::WindowStaysOnTopHint` for your QWidget. This will force your widget to stay on top of all other windows

Problem

I'm creating an application which has a "floating" widget which can be dragged around inside the application window. But it starts up, or tends to go behind other widgets sometimes. Is there any way to make sure that the widget in my application stays on top of all other widgets whenever it is made visible? Thanks.

Original source