Creating a notification banner
-
Hey there,
I would like to create a notification banner similar to the ones in Ubuntu or OS X. Essentially it needs to be frameless, [ideally] translucent, sit on a certain side of the screen, and disappear after a certain amount of time.
How can I do this?
Thanks!
-
Do you ask how to create frameless and translucent window?
Have you seen "Window Flags Example":http://qt-project.org/doc/qt-4.8/widgets-windowflags.html ? -
You need create classes from QObject and QAbstractListModel and manipulate them. Class from QObject will hold properties your popup windows as window status, window color, text message, window caption text, icon and property "was seen" for closing and deleting message from internal QList.
Window you can create using the QML Rectangle. To change the transparency of window you need use property opacity of the Rectangle
I think you need more complex understanding how connect C++ and QML.
Regards. -
Okay, I've now figured out everything except having it sit on a certain side of the screen and having it disappear after a while.
-
Maybe "QDesktopWidget Class":http://qt-project.org/doc/qt-5/qdesktopwidget.html and "QTimer":http://qt-project.org/doc/qt-5/QTimer.html .
-
How would I use the QDesktopWidget Class to place a window on a certain part of the screen? I read the docs but I didn't get it.
Thanks!
-
You don't use QDesktopWidget to place your window, but you use it to query the size of screen! This way you can determine where (e.g. offset from the upper left corner) you want to place your window. Then you can place your window at the proper location, using QWidget::move(), for example.
-
Oh okay. Could you give me a short code example of how it would find the size of the screen then offset?
Thanks for your help!
-
For example, if it turns out that the user's screen size is 1920x1080 pixels and your window is 100x100 pixels in size and you wish to put it into the lower right corner, then you'd have to move it to coordinate (1820,980).
-
Okay that seems easy enough. Ill give it a shot!