I want to minimize the borderless modal dialog so it should stay in the taskbar. The problem is, the dialog minimized to the bottom of the screen:
Screenshot:
Code:
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
setWindowModality(Qt::ApplicationModal);
this->setWindowState(Qt::WindowMinimized);
Also, this dialog is not the main window, so I think it should minimize them both when clicking minimize in the dialog and the issue is present in another non borderless modal dialog.
Screenshot with minimized modal dialog with borders:
I use Qt 5.9.2 on Windows 10. How to fix this issue? Thanks in advance.
So the issue has been fixed by removing parent or setting it to nullptr. Thanks to #Felix information, this is not a bug in Qt, it's default Windows behavior.
Related
It is possible to set application-switching window as a Modal window (see definition)?
I mean, this window appears when I press Alt+Ctrl+Tab button at the same time and allows me navigate between opened applications typing "tab" key.
The problem appears when I push/click outside the window (Application-switching window lost focus and disappears).
Are there any way to avoid this problem in C++ MFC? I have tried calling:
CWnd* appSwitchingWnd = GetTopWindow();
appSwitchingWnd .SetFocus();
But it doesn't works...
I will appreciate any kind of help.
I have a QMainWindow with three QPushButtons (arranged in a QVBoxLayout in a QWidget). All have the same properties, except objectName, icon and iconSize. All are enabled and have two icons, one for normal and one for disabled.
When I start my application, always the top most icon shows the disabled icon (but is working, so it is enabled) the other two are fine. As soon as a focusable control in that window gets the focus, the icon changes to the active one and everything is fine.
Calling update or repaint in the showEvent of the window doesn't help either.
I'm using gcc 4.8.1 and qt 5.1.0.
Any ideas how to handle this glitch?
Update: It gets more strange: Starting the program, the icon shows disabled, getting another application the focus, the icon shows enabled, bringing the window on top again without giving it the focus (e.g. by using the task bar) changes the icon back to diabled. Clicking a control in the window, which can have focus will fix it again.
Well, well I finally got it. I just set the focus manually in the code and realized, that the icons were set in a wrong way. If a button was currently focussed it displayed the disabled icon. I had messed up the different button states and too many states got the disabled icon.
I have an application which has Propertysheet dialog box with PropertyPage and dialogbox has three button at the bottom.
PropertySheet and PropertyPage create using MFC CProperySheet and CpropertyPage.
Dialog box display fine in windows xp but in windows 7 its partially cut three button
Please Help me to resolve this problem
It's probably due to the font size being something other than default size (check the DPI in the Display properties). If you're manually sizing the property sheet you'll need to be aware that the dialog units will be multiplied by a factor to calculate the size for a given DPI.
Let me clarify:
Are you embedding property sheet in a dialog?
If yes:
Is there any reason to do so?
The buttons you mention belong to a dialog or property sheet?
Are you resizing property sheet?
If buttons belong to the dialog are they cut by the bottom of the dialog?
The best if you post a snapshot of the dialog from XP and 7.
I have a native C++ MFC app. It has a main window based on CWnd, and user action can create a modal dialog. While the dialog is active, I want the main window to disappear, the dialog to be visible, and the main window's icon to remain in the task bar.
How can I accomplish this?
If I hide the main window (ShowWindow(SW_HIDE)), the task bar icon disappears. If I minimize the main window (SW_MINIMIZE), the icon remains. However, since the dialog is owned by the main window, this also hides the dialog.
After the dialog is created, clicking on the task bar icon makes the dialog visible. Naturally, I do not want to require the user to do this.
Even if I insert ShowWindow(SW_SHOW) in the dialog's OnInit handler, the dialog remains not visible. Spy++ shows that its visible bit is set, though. Same is true if I add SetWindowActive to OnInit.
I am not interested in changing the UI design. While the dialog is active, the user interacts only with it, and is not interested in anything in the main window. Therefore, the main window should disappear.
Using Windows VS2005 under WinXP32.
Well, in the block of code where you create the dialog and show it modal, you can do whatever you want to the main window of your app (show/hide) as long as you make the desktop window the parent of your dialog. Usually, the constructor for CDialog and derivatives takes a default argument of NULL for the parent window in which the framework ends up substituting AfxGetMainWnd(). Instead pass CWnd::GetDesktopWindow() as the parent of your dialog and then you should probably be able to hide your main window. However, you still might have a problem with the taskbar--but I'll let someone else give hints since I know nothing offhand about it.
In OnInitDialog, add following codes
//Set windows size zero, the windows disappear.
MoveWindow(0,0,0,0);
//If you want it invisible on taskbar. add following codes.
DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE);
dwStyle &=~WS_EX_APPWINDOW;
dwStyle |= WS_EX_TOOLWINDOW;
SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, dwStyle);
You're fighting the OS. A modal dialog, by definition, disables but does not hide the "main" (parent) window. If you wanted another window, make a second one, but don't tell the OS to treat it as a modal dialog over the first window.
Perhaps you can resize the main window to a really small size and always keep it behind the modal dialog.
I've created a popup window with SW_SHOWNA.
The problem is when I move the main window behind the popup window the popup window stays at the same place.
Is there any way to catch the click on the title bar (or other technique) of the main window behind the popup window and to close the popup window?
thanks a lot!
mike.
Yes, just do it. I would however not react to the click, as it makes your behavior mouse-bound. From your description, it seems you want to close the popup on a window move, so trap that message (WM_WINDOWPOSCHANGING) instead. This will catch keyboard-initiated moves as well.