haha, sorry for the rewrite, i just had figured it out and didnt see your reply
im using QEvent::Hoverenter but apparently its behaving like HoverMove...ie: if I move the mouse in the cell.. it still "fires"
thanks for the replys!
haha, sorry for the rewrite, i just had figured it out and didnt see your reply
im using QEvent::Hoverenter but apparently its behaving like HoverMove...ie: if I move the mouse in the cell.. it still "fires"
thanks for the replys!
Use QEvent::Enter and QEvent::Leave.
I set the delegate on a column (view->setItemDelegateForColumn(1, new BoxDelegate(this) ); ) ...but somehow when entering the mouse over the column I dont get Enter of leave, i get MouseMove... dont understand why yet....
ps: someone should have told me to RTFM the "Events and Event Filters" article in Assistant.
Did you set the hover attribute on the view's viewport?
Qt Code:
view->setMouseTracking(true); view->viewport()->setAttribute(Qt::WA_Hover,true); bool BoxDelegate::editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ) { qDebug()<<index.row(); if ( event->type() == QEvent::HoverEnter ) { qDebug()<<"enter..."; } // doesnt appear. (it does on mousemove) return 0; }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 19th March 2009 at 09:15. Reason: missing [code] tags
If you want to enable mouse tracking, you have to do it on the viewport as well (then you'll receive enter and leave events). But it's not required. After taking a closer look on a working example I think you don't need to react on QEvent::Enter or QEvent::Leave. Just reimplement paint() and check whether the mouse is currently hovering over your item.
I tried view->viewport()->setMouseTracking(true); but I still dont get any enter or Leave
About reimplementing paint, is there any example somewhere that shows how to see if mouse is over something?
In the paint implementation :
using qdebug()<<option.state; i am able to "see" a QStyle::State_MouseOver State, but in theQt Code:
void BoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) constTo copy to clipboard, switch view to plain text mode
implementation, i dont.. why is this?Qt Code:
bool BoxDelegate::editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index )To copy to clipboard, switch view to plain text mode
Probably because it's irrelevant there.
just one small unrelated question
Can i show images (.jpg,.gif) that are stored as BLOB in mysql directly in a qtableview ?
Depends what you mean by "directly". You have to read them from the database and create pixmaps out of them. Once you do that, you can show the images in a widget.
Bookmarks