Qtableview problem ( issue solved)
-
hello everyone,
i am currently working in Qtableview highlighting the row on mouse move.using paint deligate. the mouse mouse does goes in paint deligate while mouse in move , whereas same code is working fine for Qlistview . -
Hi,
Without more information like your delegate code it is near impossible to help you.
What exactly are you trying ? Having the rows highlighted when hovering the mouse over a cell ?
-
Ya exactly I want to do that
-
What does exactly not work ?
-
@ /* Paint Deligate*/
Highlight_pos *myData = reinterpret_cast<Highlight_pos >(var.value<void>());
if(myData!=NULL)int x,y,w,h; x = option.rect.x(); y = option.rect.y(); w = option.rect.width(); h = option.rect.height(); paintPen = QPen(QColor::fromRgb(18,180,22)); paintPen.setWidth(4); painter->setPen(paintPen); switch(myData->gethighliter()) { case Highlight_pos::TOP: painter->drawLine(QPoint(x,y),QPoint(x+w,y)); qDebug()<<"top"; break; case Highlight_pos::BOTTOM: qDebug()<<"bottom"; painter->drawLine(QPoint(x,y+h),QPoint(x+w,y+h)); break; break;
}
painter->save();
myData->setXaxis(x);
myData->setyaxis(y);
myData->setheight(h);
myData->setwidth(w);
}/* Drag move event */
QModelIndex dragIndex = indexAt(event->pos());
QVariant dragVariant = dragIndex.data(Qt::DisplayRole);Highlight_pos *detail = reinterpret_cast<Highlight_pos*>(dragVariant.value<void*>()); if(detail!=NULL) { int currentPosition = event->pos().y() - detail->getYaxis(); if(currentPosition < detail->getheight()/2 ) { // the problem is this pos from here it should go to deligate and show highlight detail->sethighlighter(CoreDetail::TOP); }else if(currentPosition > detail->getheight()/2 ) {
// // the problem is this pos from here it should go to deligate and show highlight
detail->sethighlighter(CoreDetail::BOTTOM); } repaint(); event->setDropAction(Qt::MoveAction); event->accept(); } else { event->ignore(); }
*/
where as same code working fine for Qlist view
*1->> while mouse mouse its not highlighting..
*2-->> where as when i drop its highlight..same code i tried for Qlist view and working well.
@ -
A QListView can be seen as a one column QTableView. In a QTableView each cell is painted separately, It's up to you to propagate the information so that the cells of the row are all painted as you wish
-
Ya I am taking as whole row but still problem remain same it's dropping dragging but on mouse in move still it's not giving highlight
-
You are getting me lost, do you have at least the current cell that is highlighted when hovering over ?
-
yes my current cell that highlighted while drag.but other not. after drop all are highlighting
-
You need to tell the whole row that it must change when you hover over a cell
-
Thanks sir working. We'll the problem was I was not updating reliant each time as it come there. Thanx for help
-
Glad you succeeded !
You're welcome !
Since it's working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)