Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DelegadoFormulasMedicion::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- if (index.isValid())
- {
- QStyleOptionButton boton;
- QRect r = option.rect;//getting the rect of the cell
- int x,y,w,h;
- w = m_ancho_boton;
- h = r.height();//button height
- x = r.left() + r.width() - w;//the X coordinate
- y = r.top();//the Y coordinate
- boton.rect = QRect(x,y,w,h);
- boton.text = "...";
- boton.state = QStyle::State_MouseOver;
- QApplication::style()->drawControl( QStyle::CE_PushButton, &boton, painter);
- }
- else
- {
- DelegadoBase::paint(painter, option, index);
- }
- }
- bool DelegadoFormulasMedicion::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
- {
- if( event->type() == QEvent::MouseButtonRelease )
- {
- QMouseEvent * e = (QMouseEvent *)event;
- int clickX = e->x();
- int clickY = e->y();
- QRect r = option.rect;//getting the rect of the cell
- int x,y,w,h;
- x = r.left() + r.width() - m_ancho_boton;//the X coordinate
- y = r.top();//the Y coordinate
- w = m_ancho_boton;//button width
- h = r.height();//button height
- if( clickX > x && clickX < x + w )
- if( clickY > y && clickY < y + h )
- {
- qDebug()<<"Abro dialogo";//aqui va mi dialogo
- }
- return true;
- }
- return false;
- }
- signals:
- void hoverIndexChanged(bool dentro);
- setMouseTracking(true);
- setAttribute(Qt::WA_Hover);
- void TablaMed::mouseMoveEvent(QMouseEvent *event)
- {
- QPoint pos = event->pos();
- QModelIndex index = indexAt(pos);
- if (index.isValid())
- {
- if (index.column() == tipoColumnaTMedCert::FORMULA)
- {
- //qDebug()<<"Estoy dentro";
- emit hoverIndexChanged(true);
- }
- else
- {
- //qDebug()<<"Estoy fuera";
- emit hoverIndexChanged(false);
- }
- }
- TablaBase::mouseMoveEvent(event);
- }
- connect(this,SIGNAL(hoverIndexChanged(bool)),dlgFM,SLOT(onHoverIndexChanged(bool)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement