The QAbstractItemView::openPersistentEditor method calls the createEditor method reimplemented in a class inherited from the QStyledItemDelegate class. It opens a widget inside the current item. But my task is to show the editor widget in some custom way. Say, under the current item, but with it's right border outside of the scroll area of the view. And it's height being far more, than just one item's height. Is there any way to do it?
It opens a widget inside the current item because the current item its parent.
One of the solutions is the following: you provide a simple editor widget which is shown inside the current item, which really does not provide editing, only data exchange.
But this editor widget creates custom widget as a dialog or as a widget whose parent is the topmost ItemView. Or you can delegate the creation of the custom editor widget to the ItemView. The result of the editing is sent to the in-item editor widget which does the job of providing the ItemView with newly edited data.
Related
I want to make a gui with QT-creator 4.9.1. Designer. My window has 5 widgets, one of these widgets must be change his visibility everytime when the user select a other menu. For that i have made a widget namded workingarea inside my window and inside the workingarea-widget i have a second widget named workingplace0001. My problem is now, that i don't know how can i create the second widget, because i can't change the visibility from the workingplace0001 widget to false. Is there any possibility to change the visibility so i can create the workinplace0002 at that place or can't i use the Designer for that?
I must create 69 workingplaces
You can use QStackedWidget. Just place it in on your main widget, then add number of pages you need, and then place every workingplace on every page of QStackedWidget. For changing current workingplace just change active page of QStackedWidget
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() .
I want to implement my own Widgets for a QListView. Like this:
If i click on this widget i want to do something.
In time, I only have experience with the QML-Version of the ListView.
Can someone explain how to insert this widget to the a QListView?
Greetings
UPDATE
In my Project i want a GUI like this:
In my first ListView I want to show items, that has a ListView, too. The text of each item can to be update.
There are 2 ways:
Set custom widget for each index: QAbstractItemView::setIndexWidget. Note: there may be problems with interaction with widgets. This way is typically used only for displaying static content.
Create custom QStyledItemDelegate and override editorEvent method. See model-view programming for details.
Update:
I propose you next design:
Create widget with image list + "dynamic content" + labels
Create ScrollArea with vertical layout and add there widgets (1.)
(2.) is prefferable than simple listview, because listview doesn't design for such cases. Listview designed for showing some data, but not to be a container for other complex widgets.
Pros: you will have fully interactable widgets.
Cons: you need to code a bit ;)
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.