Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. void DelegadoFormulasMedicion::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
  2. {
  3. if (index.isValid())
  4. {
  5. QStyleOptionButton boton;
  6. QRect r = option.rect;//getting the rect of the cell
  7. int x,y,w,h;
  8. w = m_ancho_boton;
  9. h = r.height();//button height
  10. x = r.left() + r.width() - w;//the X coordinate
  11. y = r.top();//the Y coordinate
  12. boton.rect = QRect(x,y,w,h);
  13. boton.text = "...";
  14. boton.state = QStyle::State_MouseOver;
  15. QApplication::style()->drawControl( QStyle::CE_PushButton, &boton, painter);
  16. }
  17. else
  18. {
  19. DelegadoBase::paint(painter, option, index);
  20. }
  21. }
  22.  
  23. bool DelegadoFormulasMedicion::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
  24. {
  25. if( event->type() == QEvent::MouseButtonRelease )
  26. {
  27. QMouseEvent * e = (QMouseEvent *)event;
  28. int clickX = e->x();
  29. int clickY = e->y();
  30.  
  31. QRect r = option.rect;//getting the rect of the cell
  32. int x,y,w,h;
  33. x = r.left() + r.width() - m_ancho_boton;//the X coordinate
  34. y = r.top();//the Y coordinate
  35. w = m_ancho_boton;//button width
  36. h = r.height();//button height
  37.  
  38. if( clickX > x && clickX < x + w )
  39. if( clickY > y && clickY < y + h )
  40. {
  41. qDebug()<<"Abro dialogo";//aqui va mi dialogo
  42. }
  43. return true;
  44. }
  45. return false;
  46. }
  47.  
  48. signals:
  49. void hoverIndexChanged(bool dentro);
  50.  
  51. setMouseTracking(true);
  52. setAttribute(Qt::WA_Hover);
  53.  
  54. void TablaMed::mouseMoveEvent(QMouseEvent *event)
  55. {
  56. QPoint pos = event->pos();
  57. QModelIndex index = indexAt(pos);
  58. if (index.isValid())
  59. {
  60. if (index.column() == tipoColumnaTMedCert::FORMULA)
  61. {
  62. //qDebug()<<"Estoy dentro";
  63. emit hoverIndexChanged(true);
  64. }
  65. else
  66. {
  67. //qDebug()<<"Estoy fuera";
  68. emit hoverIndexChanged(false);
  69. }
  70. }
  71. TablaBase::mouseMoveEvent(event);
  72. }
  73.  
  74. connect(this,SIGNAL(hoverIndexChanged(bool)),dlgFM,SLOT(onHoverIndexChanged(bool)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement