I need to create window, which always stays on top without borders and controls. So I did this:
MainWindow window;
window.show();
Where MainWindow class looks like this:
MainWindow::MainWindow(QWidget *parent) : QWidget(parent,
Qt::Window | Qt::WindowStaysOnTopHint
| Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint) {
}
void MainWindow::keyPressEvent(QKeyEvent *event){
if(event->key() == Qt::Key_Escape){
QApplication::exit();
} else
QWidget::keyPressEvent(event);
}
Which works, but not perfectly. After program is launched, the windows doesn't have focus, so you must first click on it.If I remove Qt::X11BypassWindowManagerHint
, window gains the focus, but than it doesn't show at all workspaces (desktops).
Question 1: What does Qt::X11BypassWindowManagerHint
actually do?
Question 2: How do I get this working?
So I managed to dig through the docs.
Question 1: Qt::X11BypassWindowManagerHint
results in window without border and no control from window manager at all (only at X11!).
Question 2: To get focus and enable keyboard input, it is necessary to call QWidget::activateWindow()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With