I would like to build an embedded Qt application. This application shall have a couple of windows which are invoked by button click. I don't know if I understood the concept of using qmainwindow in the right way:
Do I create one QMainWindow class and each other window that should be displayed is a widget placed as central widget or is any new window I call a new QMainWindow?
I do not use qmainwindow's tool, menu or status bar just the dock widgets which surround the central widget, like a header on top and a button bar at the bottom or a widget to the reight like a keyboard. Since the header's label stays the same (only the title and the icon changes) and the bottom bar always holds some button (which should call another central widget or return to the previous one), changing the central widget should be sufficient right?
Have a look at QT Layouts
http://qt-project.org/doc/qt-5.1/qtwidgets/layout.html
Remember you can nest layouts, so you probbaly want a VBoxLayout, and the second entry in that layout will be a HBoxLayout.
Related
I am trying to promote the top level QWidget into a derived MyWidget class using the "promote to" menu in Qt Designer.
For that, i have defined the promotion with the "promoted widgets.." menu.
I have also add a child QWidget (in violet) to the top level QWidget and i was able to promote into it into MyWidget using the "promote to" option, that appear after a right click in the object inspector. (as shown in the picture)
But for the top level QWidget, the right click don't give access to the "promote to" menu and i have the same problem with a QFrame.
Is it possible to do that with Qt Designer ?
Thank you.
No, you can't promote top Widget in Designer. But you can do it manually. Simply open ui file in text editor and make necessary changes to the top level widget. Which changes you will need you can see in your child widget defenition. Just copypaste needed fields and values.
I am programming in C++ in QT and trying to make a UI with dynamic tabs having tables inside each of them. For doing the same, I had my TabWidget in the main window, and another widget with just the tableView. As the tabs are dynamically being added to the main window by a button click, I make a new object of my widget and put it in that.
I also have another version of the application in which there are no tabs, just a tableView in the main window.
I am unable to open the context menu in the former case, while it works perfectly for the latter.
I am using the signal "customContextMenuRequested" in both the cases. Don't understand what I need to add for it to work when the tableView is in a child widget.
Some help please?
Thanks already!
Did you check that nothing is involving QAbstractScrollArea, it's possible that in this case it would signal/slot as expected.
This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. The position pos is the position of the context menu event that the widget receives. Normally this is in widget coordinates. The exception to this rule is QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport() .
The application I'm working on has a QTabWidget with 3 tabs, and all the tabs have QStackWidget added to it with variable number of widgets present at a time.
When I RMB on a particular widget inside a particular tab, its eventFilter gets called and a context menu pop up.
I have to add this RMB context menu behaviour on top as Banner Menu. And this Banner menu is not written in Qt but in some internal which can be converted into C++ using wrapper.
Now my problem is that when I RMB on a widget its eventFilter easily tells me address of the object ie: this and I can add appropriate slots to context menus.
But in the case of banner menus, how would I know the address of the object whose slots() I have to call. The banner menus are supposed to work for the selected/currently-visible widgets.
I am new to Qt development, even though I have years of MFC programming. I am trying to create a dockable widget and put some controls in the dock widget, a tab widget to be more precise. My problem is that the tab widget inside the dock widget doesn't resize along with the parent.
I'd like the tab widget to fill the entire area of the dock widget. Is it possible to manipulate some property in the same gui designer?
I don't know If I understood your question, but try this: click anywhere the DockWidget (and outside the tab widget) and press the button idicated by the red arrow (it will be blue). Is that it?
This:
Becomes this:
I want to create a dock widget with a custom title widget. That custom title widget has my own icons (maximize, minimize, close etc).
Source code is simply like that:
QDockWidget *dock = new QDockWidget("name", parent);
MyDockTitle * titleWidget = new MyDockTitle(dock);
dock->setTitleBarWidget(titleWidget);
When I run the program, dock widget is shown appropriately but unfortunately I can not move the dock widget (it is in floating state). What can be the problem?
P.S. When I dont use custom title widget, I can move dock widget.
Thanks...
The Qt documentation of setTitleBarWidget() says:
Mouse events that are not explicitly
handled by the title bar widget must
be ignored by calling
QMouseEvent::ignore(). These events
then propagate to the QDockWidget
parent, which handles them in the
usual manner, moving when the title
bar is dragged, docking and undocking
when it is double-clicked, etc.
So I guess you need to add some QMouseEvent::ignore() calls to your MyDockTitle class.