PDA

View Full Version : Is a Delegate a Widget?



frank100
11th August 2011, 21:33
In order to simulate a right click within a table cell with qtest::mouseclick I need to get a QWidget* pointer from that cell.

The cell is from a QTableView so I do not have the "cellWidget" function that I used to have with QTableWidget. The view has custom delegates, so using a QModelIndex I can retrieve the delegates. indexWidget(...) allways returns 0.

My problem is that I need the QWidget* of the cell being displayed (not the editor widget). I am confused because a delegate is a QObject and not a QWidget.

So to make this question easy:

How can I get the QWidget* for the cell of a table view (not the editor widget) ???

Lykurg
11th August 2011, 21:48
That's the whole point behind view and delegates: there aren't widgets... What happens if you use the pointer to the view with a proper position?

frank100
11th August 2011, 22:54
well, I still need a widget to call the qtest::mouseClick. I can still use the whole table view as the widget, and I noticed there is an optional QPoint parameter

If I am not mistaken, the X and Y of QPoint are pixels, not cell offsets, right?

I need the opposite of indexAt(), I am thinking in combining rowViewportPosition() and columnViewPortPosition() to translate the cell coordinates to the qPoint I need.

Is that the best way to emulate that right-click with qtest:mouseclick for a table view ???

ChrisW67
11th August 2011, 23:43
I need the opposite of indexAt(), I am thinking in combining rowViewportPosition() and columnViewPortPosition() to translate the cell coordinates to the qPoint I need.

QAbstractItemView::visualRect() as mentioned in QAbstractItemView::indexAt()