QTableWidget Scrolling With Selected Item - qt

So i am using a QTableWidget as a logger of sorts for a user, with new rows being inserted at the top, and bottom ones falling off eventually as i read in updates every second or so.
I am currently running these 3 commands to keep the user from being able to do anything with the widget.
summaryTable->setSelectionMode(QAbstractItemView::NoSelection);
summaryTable->setFocusPolicy(Qt::NoFocus);
summaryTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
This works, the user cant select a box(doesnt get highlighted more on that later), cant edit a box, all is good.
Except even if a user clicks on a cell, even though its not highlighted visibly there is still something allowing it to be selected such that when that cell gets "pushed" down below the current scroll area from inserts at the top the table begins scrolling down to follow this cell all the way to the bottom.
Obviously this is confusing, if a user clicks a cell within a few seconds its going to keep scrolling them down the table over and over again and it becomes a fight for them to scroll back up and click on a header or something to prevent future scrolling.
How do i prevent this? I thought by preventing selection and turning off what i did it would stop this, but there is still some type of selection happening within QT even if its not visible as its tracking the selected cell.

Oops, didnt realize there is a SetAutoScroll method, setting this to false fixed the issue.

This Method May Work QTableWidget::scrollToItem() or
QTableWidget::scrollTo() is will Work :)

You can manually scroll the item by putting row index as -
self.ui.tableWidget.verticalScrollBar().setValue(index)
OR
You can auto scroll the item by current index:
row = self.ui.tableWidget.currentIndex().row()
self.ui.tableWidget.verticalScrollBar().setValue(row)

Related

Tooltip becomes broken after editing value in the grid's cell - ExtJS6

We have encountered a subtle issue with ExtJS grid.
It is quite regular grid with standard 'cell editor' plugin and two editable columns (having at least two is important).
Once an editable cell is submitted, the store backing the grid gets reloaded.
However grid reload takes place in a subsequent time slot because it's a part of asynchrouous task completion.
All this works well unless the user submits editable cell with the Tab key rather than with Enter. Tab makes second column's cell editor visible and shifts input focus there. After that the store reloads, or at least I believe it happens afterwards.
At first glance nothing bad happens to the UI, it continues working as usual. However after some time an attempt to hover the mouse over any element to which a tooltip is attached causes crash and console gets flooded with errors.
We've been able to establish immediate reason of this: garbage collection cycle that follows grid reload treats the input field belonging to the second column's editor as garbage. As a result Ext.Element instance wrapping this field has its dom property erased. By itself it's seemingly not an issue. However, for some reason, when it comes to show a tooltip, the system tries to get its hands on the Element that was previously garbage collected. Strangely enough, that element has nothing to do with tooltips.
In order to reproduce this open the fiddle and then
Double-click any cell in the first column to make it editable
Type any value
Press Tab on the keyboard
Wait 30 seconds
Move and hover the mouse over the grid cells to view tooltips
It does not need to be a grid tooltip, the bug equally occurs even if the mouse hovering over any unrelated UI element with tooltips.
So the question is: how can it be that garbage-collected element is reused, and how to correct this?

NSTableView detect row scrolled off

I have a view-based NSTableView and each row has to generate some images which takes time. These are done on a background NSoperationQueue and started when a request for an image is made (through a binding).
When a row is scrolled off screen, if the NSOperation is still pending, I'd like to be able to cancel it, but I need to detect when a row is no longer visible. Should I be looking for the delloc on my CustomTableRowView, CustomTableCellView, or something else?
I guess I need the opposite of tableView:willDisplayCell:forTableColumn:row:
Some sort of tableView:willHideCell:forTableColumn:row:
Apple's TableView Playground has a comment:
// We would have to keep track of the block with an NSBlockOperation, if we wanted to later support cancelling operations that have scrolled offscreen and are no longer needed. That will be left as an exercise to the user.
I can cancel the operation, but I am not sure how to detect when a row is scrolled off.
I believe this is solved with
tableView:didRemoveRowView:forRow:
though I am not sure if it is called immediately after the row scrolls off or a short while later.

How to avoid `index exceeds maxCellCount` when deleting an item at the scrolled bottom of a combobox?

In JavaFX I use a ComboBox containing a New... item that allows to create a new entry. Once it is created and selected, a Delete button allows to remove it.
Adding the item, then scrolling to it in the ComboBox and finally clicking the Delete button shows the following message:
janv. 04, 2016 2:25:01 PM com.sun.javafx.scene.control.skin.VirtualFlow addTrailingCells
INFO: index exceeds maxCellCount. Check size calculations for class com.sun.javafx.scene.control.skin.ComboBoxListViewSkin$2$1
If I do not scroll to the item, it doesn't show this message when it is deleted.
Is there anyway I can avoid this output ? I tried to find a way to scroll back up but failed.
EDIT I currently removed that error using a listener to adapt the visible row count. Although that will probably cause me trouble if the list grows too big:
list = FXCollections.observableArrayList(baseElements());
list.add("New...");
list.addListener((ListChangeListener<String>) change -> combo.setVisibleRowCount(change.getList().size()));
combo.setItems(list);
That removes any scroll as the combo will grow depending on it's contents and thus the error cannot occur anymore. That's not what I expect for a solution though.
Have hou tried reseting the actual item in the combo box before deleting it with something like the code below?
Object value = combo.getValue();
combo.setValue(null);
combo.getItems().remove(value);

Infragistics UltraWebGrid - Selected Row changes randomly

We are using Version=11.1.20111.2064 of Infragistics35.WebUI.UltraWebGrid.v11.1 and we are experiencing trouble in selecting a row. When a person selects a row near the bottom of the grid, the selected row changes to a row near the top after a few seconds. While mousing over the grid, the control seems to refresh itself a couple of times. In the end the user is frustrated because they never see the row they selected unless it is at the top.
What could be causing this? I know that I can override the client side events, but I am not sure if this is the right approach. I have the same control on another page and it does not behave the same way.
DH
Do you display any alert messages to the user in AfterSelectChangeHandler event? If so it could trigger a bug when mouse move causes row selection. If that's the case add at the end of your AfterSelectChangeHandler handler:
igtbl_getGridById(gridName).Element.setAttribute('mouseDown', 0);
Ref: http://codecorner.galanter.net/2011/11/15/ultrawebgrid-bug-row-is-selected-on-mouse-move/

Qt drag and drop animation

I have two QTreeViews side by side and I want to implement dragging one item from one table into the other table. What I would like to do however is that when the item to be dropped reaches the destination table, that the two rows sort of "make space for it" and separate to really show the user exactly where the item would be dropped. Could someone point me in the right direction as to how to do this as I have no idea really where to start.
Thanks,
Stephen
http://doc.trolltech.com/latest/dnd.html should lead you to pretty much anything you want to do re drag and drop.
As for your specific goal, you need to implement QWidget::dragMoveEvent(QDragMoveEvent* event), which will get called every time the mouse moves within the destination tree while dragging an item. Then get the position of the cursor with QDragMoveEvent::pos(). After that, while in dragMoveEvent, use QTreeView::indexAt(pos()) to get the item under the mouse. Now, I don't know how to get the items to separate in a smooth animated way, which would be ideal. But what you can do is (temporarily) add a blank item to the list, which will have the almost identical effect. Then implement QWidget::dropEvent() to handle the drop event, and when this happens delete the blank item and insert the dragged item in the location where it was.

Resources