[Solved] How to add QSpinBox as QItemDelegate and activate it without doubleclick
I added QSpinBox as QItemDelegate to my tableview column using "this example":http://qt-project.org/doc/qt-5.0/qtwidgets/itemviews-spinboxdelegate.html.
That spinbox only activates when I double click on the column. I need to already activated spinbox when load the dialog.
Thanks in advance.
When I had the same problem I have used the QAbstractItemView::openPersistentEditor method by looping through all the affected fields of my model every model changes. I know that this is not the most elegant way, but I do not know better method right now.
Thank you very much for your solution.
It is working fine now.
And shall I mark this as [solved] or keep it as unsolved? I'm asking this because you told this is not most elegant way.
that's exactly the purpose this method is there for.
A nicer solution would be to avoid such design at all where you need an persistent editor.
But as long as you keep the number of editors down you wont notice any performance drawbacks.
E.g. don't open an persistent editor on every row in a very big table. Use QWidgets instead or redesign your application.
Thanks for the reply. I think less than 20 rows won't be a problem. I'll keep your advice in mind.