1 Attachment(s)
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
in my_model::data I added a:
Code:
if(role== Qt::EditRole ) {
return QString(index.
data(0).
toString());
}
since I read on http://wiki.qtcentre.org/index.php?t...tractItemModel
that Qt::EditRole returns a string, and now upon doubleclick the values "stay" in the cell.
But the story isnt over, I still dont understand how to use QSqlTableModel 's delegates on my_model too :(
(i have a datetime type in mysql which automagically has a spinbox editor in QSqlTableModel )
Someone should further edit the wiki article with examples of the functions :)
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
bump.
I still havent solved the last issue... :crying::crying::(
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
Quote:
Originally Posted by
georgep
It returns a variant. The default delegate interprets it as a string later on. So you can return an int from this role and it will be displayed as a textual representation of the integer.
Quote:
But the story isnt over, I still dont understand how to use QSqlTableModel 's delegates on my_model too :(
(i have a datetime type in mysql which automagically has a spinbox editor in QSqlTableModel )
I don't understand the problem. What is it exactly that you don't know?
Quote:
Someone should further edit the wiki article with examples of the functions :)
Hmm... why don't you do it?
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
Quote:
Originally Posted by
wysota
It returns a variant. The default delegate interprets it as a string later on. So you can return an int from this role and it will be displayed as a textual representation of the integer.
I don't understand the problem. What is it exactly that you don't know?
it might be simple, but I dont understand how to get the spinbox delegate in the datetime column of the database (and not in others)[see pic]. I searched for the code in
src\sql\models\qsqltablemodel.cpp but couldnt manage to find anything...
Quote:
Originally Posted by
wysota
Hmm... why don't you do it?
Because im very new to Qt, and not very experienced in cpp either so there is a significant chance i would write something stupid.
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
Quote:
Originally Posted by
georgep
it might be simple, but I dont understand how to get the spinbox delegate in the datetime column of the database (and not in others)[see pic]. I searched for the code in
src\sql\models\qsqltablemodel.cpp but couldnt manage to find anything...
Because it's nothing related to the model. You need to provide your own delegate - subclass one of the existing classes and reimplement QAbstractItemDelegate::createEditor() to return a spinbox for the appropriate column or datatype.
Quote:
Because im very new to Qt, and not very experienced in cpp either so there is a significant chance i would write something stupid.
So please restrain yourself from such statements. It's either writing examples at the wiki or answering questions here. The time and will of people willing to help is limited -- don't reduce their motivation even more, please.
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
Quote:
Originally Posted by
wysota
So please restrain yourself from such statements. It's either writing examples at the wiki or answering questions here. The time and will of people willing to help is limited -- don't reduce their motivation even more, please.
Thanks for the suggestion, i will reimplement a delegate class.
What statements :confused: ??? I think you might have misunderstood me (my fault probably), I was merely speaking about miself, and i never commanded anyone anything...:confused:
cheers
Re: How do I obtain mouse hover/popup functionality in a Qtableview?
Quote:
Originally Posted by
georgep
I have subclassed QSqlTableModel in order to have a DecorationRole, no problem there.
Problem is that when editing (double click on a cell) with My_model the cell turns blank and Remains blank after the cell looses focus.. (of course i dont type anything).
With QSqlTableModel when i click a cell the contents remain there...
I get the same behavior with or without my own setData(..) .
Tried having return QSqlTableModel::setData(index,value,role); in my setdata() but no success....
Whats the trick? I am speculating that i am loosing the delegates used by qsqltablemodel....
How did you achieved this... I am trying to do the same but no luck. any hint or advice?