PDA

View Full Version : How to show custom widget in TreeView's cell :-/



WolfMM
6th July 2007, 16:57
Hi everyone!

I'd like use QTableView for presenting data both numerical/text and presented as chart using my own custom widget. Partially I managed to solve my problem.

My QTableView is one of objects of my QMainWindow class. In QMainWindows constructor I create tableView object, add model for it and my delegate class.
Basing on SpinBox Delegate Qt's example I made my own spin box delegate which shows chart for specyfic columns. But it doesn't work exacly like in SpinBox Delegate example. When I click on specyfic cell it doesn't show my delegate. Besides I don't want to click on cell to show my delegate at all, but I thought to myself I can start like this.
Then I added connectin between signal clicked from QTableView to window slot function, which does:
tableView->openPersistentEditor (index);

I thought it solves problem with hiding delegates when I click somewhere else on TreeView. Unfortunatelly it doesn't. :-(
Besieds I still don't know how to force TableView to show my delegate class objectes (and connected with them my custom widgets) automaticly in specyfic columns (usually first from right, but It can be even 10 columns from right).

Thanks for reading my problem. I appreciate any sugestions.
Best regards!
Wolf

jpn
7th July 2007, 09:39
When would you like a custom editor to be shown?
When would you like it to be closed?
In what way does it work differently than spinbox delegate?
Actually the delegate itself is nothing visible, but it does render items and provide editors.
Could we see the delegate code?

WolfMM
7th July 2007, 11:16
All right...
Problem solved... Don't use a gun, where fly swatter is good enough.
There is QAbstractItemView::setIndexWidget (QModelIndex&, QWidget*) function and that's all folks. I was looking for in wrong direction :-\

But thanks anyway :)