[ACCEPTED]-Show window in Qt without stealing focus-active-window
It took me a while to find it but I found 2 it:
This forces the window not to activate. Even 1 with the
If you want to make floating preview box/ any 3 other widget just use below
thumbnail = new QLabel; thumbnail->setAttribute(Qt::WA_ShowWithoutActivating); thumbnail->setParent(0); thumbnail->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
Qt::Tool is important 2 flag to make it work. I mean not stealing 1 focus.
Widgets don't accept focus by default but 9 presumably you haven't created a plain widget? Which 8 subclass was it? QMainWindow or something 7 else?
It's possible the window subclasses 6 default to accepting focus so try explicitly 5 calling QWidget::setFocusPolicy with Qt::NoFocus 4 before calling QWidget::show().
Also, make 3 sure you're not calling QWidget::activateWindow() on 2 the window or any of its widgets at any 1 point.
More Related questions