QMenu is crossing the parent window frame? - c++

I am using QtEmbedded-4.8 for my development project. A typical problem I am facing, is with the behavior of QWidgets.
I have used QMenu API for handling with menu. Problem is when a particular multilevel menu is opened, sometimes it is crossing the frame of the parent window.This thing should not happen in case of my project. I want the menu widget being displayed within the frame of parent window all time....
How to resolve this issue?

Related

Qt::Popup window flag and parent widget mouse event

I want to create QCombobox with tree models support where each child list displayed in new window just like it happens in QMenu (without using QTreeView) but with QListView display features. All is going fine except one small thing: i lose all mouse events for parent widget when child popup is opened. So my question is how to keep taking mouse events during child popup is opened?
In qt basic example Window flags widget with Qt::Popup lose mouse event too. But in QMenu submenu been closed when mouse leave from parent action field. I mean this behaviour is supported by Qt and may be reached from the mox but it's hidden and I can't find a way to give it.
Qt::Tool or Qt::ToolTip modes give me necessary behaviour for parent widget but child widgets do not track mouse events for it's self

QAction with icon displays checkbox on top

I have a menu with checkable QActions in it: (ed: these calls are within a QWidget subclass, so 'this' points to the associated widget).
QAction* action = new QAction(icon, actionName, this);
action->setCheckable(true);
action->setActionGroup(m_actionGroup);
menu->addAction(action);
This menu is attached to a tool button, which is in a QWidget with a few other tool buttons. Previously, it was part of a larger widget, but I've been refactoring to confine some things together.
When it was previously part of the larger widget, these actions and their icons displayed fine. Now, however, the icons are drawn in a dotted pattern and a box for a check box is drawn on top. When I hover over an action, the dotted action goes away entirely, and it's just the check box. When I select an action, the icon appears normally.
I've tried doing the same in a little toy program, and the menu displays correctly then, so I'm having trouble reproducing the issue outside of my rather large program. Has anyone seen behaviour like this before, or know how to fix it?
Qt 5.5 on Ubuntu 16.04 is the platform information.
Edit: It gets even stranger. The original implementation created the QMenus without parents. Which I would have avoided because of memory leak concerns. But if you create the menu with the widget holding the button as a parent, then you get this behaviour. It's something about the QMenu being constructed with a parent that is creating issues, not the QAction.

How to change UI without opening a new window in Qt?

In my program, I'm moving from QMainWindow to QDialog on a press of a button.
I want to do the same without opening a new window and be able to move between the UI's.
The Target device will have a very small touchscreen, so I want my UI to sit still and require minimal repositioning.
Please point me in the right direction or give me an example on How-to.
To do that, you can use a QStackedWidget.
From the documentation:
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.
Instead of opening a new window, push its content on top of the stack and pop it when you want to (let me say) close the window.
Each widget is a page of your application and no separate window is required. You can design them as you would design a central widget of a normal window or dialog.

MFC floating CDialog control clipping issue

I am making an SDI MDF application that uses a frameview to provid the user with a set of controls (buttons, editboxes and such). The view also owns a set of CDialogs used to desplay aditional controls that can be can be shown or hidden via a tabcontrol and other means. Untill recently the dialogs have been staticly placed at creation to be in their proper location on the screen but I wanted to add a dialog that the user could move around but is still a child of the view. When I created a dialog with a caption and sysmenu that the user can move around the issue I am running into is that when the window is placed over another control owned by the view, (lets say a button) when the paint method is called on the button, it draws over the dialog. The dialog is still on top and the dialogs controls can still be interacted with but the button is drawn over them untill the dialog is repainted. I have tryed to change the clipchild and clipsiblings settings of the dialog and have been able to get the dialogs to properly clip eachother but can not seem to get the child dialog to properly clip the parent view controls. Does anyone have any ideas on what setting might fix this clipping issue.

How To Change Panel/view in the Windows Client Area in MFC

I want to design a student registration and exam recording app using C++ MFC with a kind of child window containing buttons edits and other common controls which is displayed on the app client area, and can be removed and replaced with another one by clicking a button. Thats the problem i face now( The GUI ). I came from JAVA background where this can be done by creating a JPanel as a container for the buttons, combo boxes and text fields controls. the panel is displayed on the client area and can be removed and replaced with another panel containing a new set of controls. I tried learning CView but it keeps talking about documents and views that displays untitled document as in word processing. Any pointer will be appreciated. Thanks.
After having searched and read a lot about my problem, i decided to go into win32 API where everything is possible depending on your awareness.The solution is as simple as creating a main window and creating any number of child windows who uses the main window as parent and all has a hiden window attribute. Then you can create controls on each child window. To switch between the child windows I did this: ShowWindow(childWindow1, SW_HIDE); ShowWindow(childWindow2, SW_SHOW);. thats it, only that the repaint process after restore does not repaint the child window's controls and its child window.