I need to have app running in fullscreen mode.
For that I used QDesktopWidget. When windows taskbar is lock it work fine.
Problems start when taskbar is in auto-hide mode.
I cannot find any way to receive information (signal), that taskbar size on desktop changed,
so I cannot react and change my widget size.
Is there any way to obtain information that windows taskbar changing from hidden to visible or opposite?
I would be glad about any hints.
Marek
I don't know why you use QDesktopWidget for running in fullscreen mode! You can simply set your MainWindow state to fullscreen by :
this->setWindowState(Qt::WindowFullScreen);
Related
I have a small Qt Desktop application (in C++) which I need to make it work in a touch screen device running Window 10. The device has a touchscreen and application works perfectly with keyboard and mouse.
I am not expert in developing Qt Application and that's why unable to resolve this could be silly isssue.
However, when I try to use touchscreen, the last touched QToolbutton remain pressed even if I have moved my finger away from the touchscreen and when I touch somewhere else, then that QToolButton is released.
I expect the Qtoolbutton to behave just like when it is pressed using a mouse. Once I move my finger off the touchscreen, it should be released.
I tried to resolve this issue with the following:
btn->setAttribute(Qt::WA_AcceptTouchEvents);
And
qApplication.setAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents);
But it didn't help. I think I am missing a very small issue and after that Qt will handle all the touch related events on it's own and will show the right behavior.
I am cross-compiling on my Ubuntu machine using MXE. Qt version is 5.12.
I think I am missing a very small issue and after that Qt will handle all the touch related events on it's own and will show the right behavior.
QWidget subclasses, including QToolButton, do not handle touch events on its own. It is not even needed that Qt emulate mouse events. You are seeing the effects in your application of emulated mouse events synthesized by Windows. This makes possible for ancient Windows programs designed to be used with mouse will work somewhat in modern touch enabled Windows tablets. But the mouse emulation is hardly perfect.
If the behavior is unacceptable for the QToolButton class, you have the option of subclass it and handle touchevents as you see fit, overriding mouse events as well, to avoid the synthesized events to be handled as well.
I had the same problem. I solved it by changing the signal to which the slot is connected.Previously I was connected my slot to QPushButton::pressed. To fix it, change the connect to use the signal QPushButton::clicked:
connect(my_button, &QPushButton::clicked, this, &MyClass::onMyButtonClicked);
I'm building the UI for an application using Qt and QML for Ubuntu Linux. I have a viewer window with a canvas element which is supposed to be fullscreen by default. On opening the application this works fine (i.e. Ubuntu sidebar and top taskbar are hidden). However, once I minimize my application and then maximize it again by using viewer->setFullScreen();, the Ubuntu sidebar and top taskbar are still visible and there is an offset while writing on the canvas due to the same.
Any help would be appreciated.
According to this topic on askubuntu, your problem do really looks like Unity bug (or feature). But, according to somehow related bug on Launchpad, it seems that you can get desired behavior by:
Turn "Always On Top" on via right-clicking the titlebar of your window, before making it go fullscreen.
This will prevent the Unity panel from rendering on top of this fullscreen-window, when using the other screen.
In Qt you can set Qt::WindowStaysOnTopHint to your window/widget via QWidget::windowFlags.
Pay additional attention to notes in official documentation:
This function calls setParent() when changing the flags for a window, causing the widget to be hidden. You must call show() to make the widget visible again.
About Qt::WindowStaysOnTopHint -- Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.
Hope this helps.
I have a Qt application with borderless window. So, I am creating my application window with CreateWindow() and then I have QWidget which uses the HWND.
Everything works fine, except that when the application is maximized and the Windows taskbar is set to auto-hide. In that case, if I click on the application icon, the program is not minimized. Even stranger is the fact that this only happens if the application is on my primary monitor. If it's on another monitor, everything works fine. Or, if the taskbar is not set to auto-hide, everything works fine on any monitor.
When the taskbar is set to auto-hide, on my primary screen the taskbar wasn't even showing up, so I am showing it with ShowWindow(hTaskbar, SW_SHOW). When it shows up, everything works when I click on the icons of other applications, so there must be something wrong with mine, but I am not sure where to start.
You need to handle WM_SYSCOMMAND and respond to SC_MINIMIZE.
WM_SYSCOMMAND on MSDN
I have created a program that runs alongside an application in fullscreen. I would like the QMessageBox from my program to be displayed on top of the application that runs in fullscreen.
The platform is Windows 7 and i am using Qt.
I have tried:
QMessageBox *msgBox = new QMessageBox;
msgBox->setParent(0);
msgBox->setWindowTitle(title);
msgBox->setText(text);
msgBox->setWindowFlags(Qt::WindowStaysOnTopHint);
msgBox->show();
With no luck. Any hints?
Try msgBox->raise(); will notify the user in taskbar, using setWindowFlags(Qt::WindowStaysOnTopHint); you eventually could make it stay on top (evtl. minimize/restore).
But a windowmanager, not depending on os, by design should not allow any application to just "steal" the focus from another application, therefor the user still needs to activate (click) your window for gaining focus.
I want to hide system cursor for 10s for some reason ,but I found
cursor.setShape(Qt.BlankCursor)
can only hide mouse cursor that is associated with QWidgets ,not in system wide ,i.e. when mouse cursor is hovering on QWidgets, it is invisible ,otherwise it is visible ,so is there any way to hide system cursor in system wide?
The win32 system call ShowCursor works per-window only. You can access this from either ctypes or pywin32's win32api. But apparently the cursor drawing is controlled by display driver and can only be affected by specific windows. You can't force another window to hide its cursor. Two options:
use ShowCursor(False) on your window, and for the display background, create a root window application that you spawn from your GUI app, it hides cursor; your app would cause it to exit after 10 seconds, but again if user moves mouse over other app windows they will see cursor.
make your application a root window application; then while in view, ShowCursor(False) will make cursor disappear everywhere on screen except system toolbar (which is a good thing).
I don't think it is a good idea anyways; what if your app crashes while the mouse is hidden? Then user can't use their desktop easily. Definitely good reason that this is not allowed.
Best approach is to think of a different solution to whatever problem led you to try cursor hiding.