QListView drop indicator styling - qt

I am using QListView to show a list of items that I can drag and drop to change their order.
The problem is that:
the drop indicator is just a very small line (1px thickness)
the drop area is so narrow so one needs to be really accurate to drop an item correctly between two other items.
I wonder if it is possible to change the styling of the drop indicator of QListView so the line is thicker and the drop area is wider.

Style of drop indicator can be changed using QStyle. QStyle::PE_IndicatorItemViewItemDrop enum value corresponds for it and can be used for setting style for indicator that is drawn to show where an item in an item view is about to be dropped during a drag-and-drop operation in an item view

Related

How to easily recognize searched item in a dense QGraphicsScene?

I have a QGraphicsScene with many QGraphicsItem like circle, rectangle, polylines, arc etc.
Every QGraphicsItem has a name. And I have a Search feature which highlights searched items using that name. When scene contains fewer items, highlighted items are seen properly. But when scene contains many items ( 100 + ) then identifying the highlighted item becomes difficult. For that I need to scroll up - down or left - right to check where is that highlighted item is.
So I want my highlighted item to be easily recognizable.
For that I was suggested, some approach like
Take searched item in front
Or
Add some marker
But I do not know, how to implement it , which Qt class should I use etc.
QGraphicsScene displays items depending on their stacking, i.e., when you call .items(), the first item in the QList is the topmost item on the scene.
The ordering of the items is depending on their respective Z-values which you can set for the QGraphicsItem by calling .setZValue()
You can read more about this on the following link: https://doc.qt.io/qt-5/qgraphicsitem.html#sorting
As for your question on how to put them in front. If you implemented your own children classes of QGraphicsItem, you can add a method or a slot to toggle them "on-top". E.g., all of the items usually have a Z-order of 0, so your method could just set it to 1 when the item is highlighted and revert it to 0 when it's not.

Getting rid of blank area at the bottom of a QListWidget

I'm using QListWidget with setItemWidget and when adding items to the list and scrolling down to the bottom I get this result:
So there's an area which is completely blank at the bottom (not selectable, in the image above the last item in the list has been selected)
How can I get rid of this blank area at the bottom of the list?
Please note that the height of the rows can be different within a list
Grateful for help and with kind regards,
Tord
It's possible to change the type of vertical scrolling that is done for list by using setVerticalScrollMode for the QListWidget so that the scrolling is done per pixel (instead of per item which is the default):
self.list_widget.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
The result is that rows that are in the top-most part of the QListWidget box can be drawn only in part, which in turn means that the blank area that exists when scrolling per item will disappear:
Reference documentation:
https://doc.qt.io/qt-5/qabstractitemview.html#verticalScrollMode-prop
I'm using exactly the same approach and I get rid of the blank area by creating a widget that contains my QListWidget and use :
listwidget.setFixedSize(widget.width(), listwidget.sizeHintForRow(0) * listwidget.count() + 2 * listwidget.frameWidth())
listwidget is you QListWidget object
widget is the widget that contains your QListWidget object

Selected Item losing Highlight in QTableView

I have a problem with the extendedSelection of my QTableView.
The Problem is that i have some whitespace around my columns and rows and when i click this whitespace the highlighting of my selected Fields is lost.
Its not ocurring when i click somewhere else in my application, only in the whitespace.
Also when i set the selection mode to SingleSelection it works just fine.
here is a short gif to illustrate the problem
https://gyazo.com/8e4ae161aaff25a4afa1b588579ddd01
thank you everyone who can help me
sincerely
Because that white region belongs to QTableWidget, so when you click that place it resets the selection and selected cell is gone since none of cell is selected. But when you click outside of the QTableWidget, selection state still exists.So If you do not want to this, you can increase column widths like this:
ui.tableWidget->setColumnWidth(columnNumber,columnWidht);
or you can decrease the width of QTableWidget to fit the columns. So user can not see and click this white region.

highlight item in spark list

I have two spark lists and want to drag items from one list to the other. When im dragging an item and over the other list item, i want the target item to change the background coloer.
Basically instead of showing the black line indicating that I will drop between elements, I want to see the target item highlight.
Thanks in advance.
Edit: Something that would look similar to this drag and drop:
(source: blogspot.com)
I would ask you to point out a UI precedent where this is standard / expected behavior.
When you drag an itemA onto itemB; and itemB is highlighted somehow, it usually means you're dragging into ItemB. But, in this case you are not dragging item from List1 into the item from List2. [I assume at least].
You'd have to override the list code drag and drop features to make this happen.

Flex: change item Style on certain Tree based ItemRenderers

I have a question concerning Tree items. I want to show where a drop action would be placed... The item will be placed in between two existing elements. So what I want to do is, to take the upper item and draw a line underneath it. But I struggling to address the itemRenderer...
I have the index for the itemrenderer, but I dont get a instance of that object.
Any help is appreciated!
Markus
If you're doing drag & drop right, it should be showing a line where you are going to drop the dragItem. That is standard behavior. You shouldn't have to do that in the itemRenderer.

Resources