Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my Qt-application I open a URL in the default-browser. Afterwards I want to bring the main-window of my application to the front again.

I tried all approaches I could find but none worked. All it does is blink in the taskbar (of Window 7) Here’s an example:

this->viewer->show();
this->viewer->raise();
this->viewer->activateWindow();

*viewer is a pointer to a QmlApplicationViewer which is derived from QDeclarativeView

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
447 views
Welcome To Ask or Share your Answers For Others

1 Answer

try this:

viewer.setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
viewer.raise();  // for MacOS
viewer.activateWindow(); // for Windows

it work in my project ( in my project viewer is QMainWindow): https://github.com/iptton/Rythem .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...