Drag and Drop different item text - c++

I have two QListWidgets , one named “Commands” on the left side and other named “XML Script” on the right side , I am able to drag and drop items from one List to another, How ever, when I drag one item, I don’t want drop that same item text, I want some changed text to be dropped.
Example: In this example when I dragged “SetScroll Command” from “commands” QListWidget and I am trying to drop this in “XML Script” QListWidget , I need some different text to be dropped like
If I drag ‘Pause Command’ from “Commands”, the dropped item in “XML Script ”should have item with text like “This is a Pause Command”?
How can I achieve this,
I am intending to keep a Map data structure which will have key as “Pause Command” and Value as “This is a Pause Command”. Whenever key text is dragged , value text shall be dropped,

Related

Implement modular drag & drop system for QListWidget

I tried to implement a modular drag and drop system for this window, which has a lot of QListWidgets in other tabs.
Currenty, the user is only able to copy the items from the right QListWidget (at the button "Tools"). But now I want to implement a simple option to copy all selected QListWidgetItems from any QListWidget.
My plan
Drag the selected items out of the QListWidget
A section with a button named "copy" appears
The user drop the dragged QListWidgetItems on the copy button
The copy button disappears
The result is a QList<QListWidgetItem*> with the dropped QListWidgetItems
The problems
(-)
I'd need a signal when the drag starts / is called
(-)
I'd need a signal when the drop starts / is called
How to get QList<QListWidgetItem*> (or QListWidget::selectedItems)?
I want a modular opportunity (for example with a pointer to the QListWidget) because I don't want to copy some code. For example, I have 12 QListWidgets and for each 3 actions. If I want to change a litte thing, I need to do that 36 times.
Is it possible without subclassing?

Winforms controlling controls

I couldn't think of a coherent search term for my problem so please forgive me if this has been asked before.
I have 24 combo boxes sitting on a panel control, displayed in 4 rows of 6.
After the user defines the value for each combo and hits the "go" button, I add all combo boxes to list so I can use the values in another section of my program.
The problem is that the order the comboboxes are added to the list is messed up, compared to their visual layout on the panel, and I would like to define the order. Currently, it adds the 9th combobox to the list first then the 20th, 2nd, 16th etc etc.
I tried TabIndex but that didnt work.
Before I manually rename and relabel all of the boxes, any other suggestions will be gratefully received.
The controls of your form exist in Controls collection of the container controls, for example when you add a Panel and a Button to a Form and two ComboBox to the Panel, then:
Form.Controls contains button1 and panel1
Panel.Controls contains comboBox1 and comboBox2
Controls are added to the Controls collection, with the same order that you add them to designer. Open designer.cs, look at the end of InitializeComponent to see the order.
You can also see/change the order using Document Outline window.
That said, now it should be obvious that panel1.Controls.OfType<ComboBox>() returns combo boxes with the same order that you see in Document Outline (or based on their z-index, and it doesn't have anything to do with their x/y placements).
You may want to order them based on TabIndex, or any other property that you like:
panel1.Controls.OfType<ComboBox>().OrderBy(x=>x.TabIndex)
Note
In general, if you are going to use those values for a search, instead of relying on the order of values, a much better idea is creating a SearchModel class which has a few properties, the set those properties to the selected value of the corresponding combo box (manually or using databinding) then pass the search model to the other classes.

wxWidgets: Delete content of wxGrid cells by selecting and pressing DEL?

By default a wxGrid acts like that: If a cell or multiple cells are selected and DEL/Backspace is pressed, the cursor jumps into the (first) cell selected and deletes the first character in that cell.
Is it possible to have an Excel - like behaviour in that when this action is performed, the whole content of the cell(s) is deleted?
Just handle wxEVT_CHAR for wxGrid yourself and clear the cell contents when you get an event for one of those keys.

Start drag action from a menu item

Given a QTreeView I would like to provide the user a means of inserting new items. For this I created a QMenuBar that contains several categorizing sub menus that in turn contain the different kinds of items the user can insert.
My first implementation was to select some existing item in the tree and then pick a menu item which is then inserted as a child of the selected item in the tree. There were buttons for rearranging the items, such as 'move up', 'move down' and so on. Later I replaced these buttons by a drag&drop interface where the user can simply drag items in the QTreeView around to rearrange them, which seems quite intuitive to me.
Now inserting new items into the tree by clicking menu items still feels annoying. In my opinion a more natural approach would be to drag the items out of the menu and into the desired location of the tree.
So is there a sensible way to implement this behaviour? My problem is how to start a drag operation by clicking a menu item as the triggered() signal is just emitted when the user releases the mouse button. But with the mouse button released, there is no drag anymore...

AutoSuggestion in Combobox

I created a Combobox with CreateWindowEx. Everything goes well. But I would like to make a final feature: AutoSuggestion. The Combobox is used to do search text in a document, hence at some point, it have items that are the strings a user searched. The AutoSuggestion should be: drop down the list of items, find those items that begin with the string that a user typed in the edit control, but do not select one of them, do not display all other items, and finally do not change select item when keydown or keyup occurs, only highlight the item and select only when a user press Enter. Do you have any idea how to accomplish this task?
It sounds like you want Autocomplete functionality.