How can we create a tiny notification window using QML without a title bar? For example, look at the picture. This notification seems like created by GTK.
can we create on like this using PyQt5 and QML
QML is very flexible language, you can create almost whatever you want. In your case I would use some system tool, since it't cross platform and works as expected. But you always can create some custom window, for example:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5
import Qt.labs.platform 1.1
Window {
visible: true
width: 400
height: 100
RowLayout {
anchors.centerIn: parent
Button {
text: "systray message"
onClicked: {
systray.showMessage("title", "message", SystemTrayIcon.Warning, 2000)
}
}
Button {
text: "custom message"
onClicked: {
popup.show();
}
}
}
SystemTrayIcon {
id: systray
visible: true
icon.source: "qrc:/ok.png"
icon.mask: false
}
Window {
id: popup
flags: Qt.FramelessWindowHint
x: Screen.width - 350
y: Screen.height - 150
width: 300
height: 30
Rectangle {
anchors.fill: parent
color: "black"
Text {
anchors.centerIn: parent
text: "Some custom message"
color: "white"
}
}
Timer {
id: timer
interval: 2000;
running: false;
repeat: false
onTriggered: popup.close()
}
onVisibleChanged: {
if(visible)
timer.running = true;
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.