QWidget top level widget
-
@mrjj yep.
So, I have Qt-widget based application. Also I have notification widget which must be pop up on the selected screen/monitor in right bottom corner. Like Windows notification center or how in MS Outlook.
User can select the screen which display that popup widget.
Idially I need something like this:MyPopupWidget::show(QScreen *screen) { show(); windowHandle()->setScreen(screen); }
-
@Alexey-Serebryakov
Ohh.
Like Win 10 Toast messages?But you must run on other platforms and prefer your own ?
https://doc.qt.io/qt-5/qtwidgets-desktop-systray-example.html
also for full blown usage
https://github.com/mohabouje/WinToast -
Ok, it must be totally custom.
QSystray also had issues on ubuntu over the years.So is the message also clickable like Toats are or is it more like a tooltip type ?
-
@mrjj Yes there popup widget has title, text, image, close button, links and so on. User can click them and follow to the main window by context dependency. Also popup widget can contain other user-defined custom widget.
-
Oh so its a FancyToast widget ;)
Well it should not be that hard to place it. and the rich part sounds lovely.
Do notice on some virtual Desktops, its like one big screen and you will have to move your window
to right x pos as there will be only 1 screen. -
Instantiating a
QWidget
and callingshow()
create a series of events that get processed asynchronously. It cannot be safely assumed thatwindowHandle()
returns a valid pointer right after construction and/or callingshow()
. You might be more lucky on Win10, than on UBuntu/X11.If you want to wait for the widget to be fully constructed, you have to wait for
windowHandle() != nullptr
, e.g. bywhile (!w1.windowHandle()) a.processEvents();
QWindow::isExposed()
tells if the window has been rendered on a screen. -
@Axel-Spoerl thank you,
consider example code above,
how can I show w1 widget on first monitor and w2 on second?
Now both widgets showing on the same primary monitor. -
how can I show w1 widget on first monitor and w2 on second?
Suggest you take a look at the documentation and examine
QWidget::setScreen(QScreen *screen)
.