Skip to content

Instantly share code, notes, and snippets.

@danieldk
Created May 16, 2012 10:07
Show Gist options
  • Select an option

  • Save danieldk/2709225 to your computer and use it in GitHub Desktop.

Select an option

Save danieldk/2709225 to your computer and use it in GitHub Desktop.
Decrease flickering in Dact OS X
diff --git a/src/PopupItem.cpp b/src/PopupItem.cpp
index 7f656be..808868c 100644
--- a/src/PopupItem.cpp
+++ b/src/PopupItem.cpp
@@ -24,7 +24,7 @@ QRectF PopupItem::boundingRect() const
QRectF PopupItem::rect() const
{
QSizeF popup = size();
- return QRectF(QPointF(-popup.width() / 2.0, -34.0), popup);
+ return QRectF(QPointF(-popup.width() / 2.0, -popup.height() / 2.0), popup);
}
QFont PopupItem::font() const
diff --git a/src/TreeNode.cpp b/src/TreeNode.cpp
index 39d2188..7bcbaa9 100644
--- a/src/TreeNode.cpp
+++ b/src/TreeNode.cpp
@@ -74,14 +74,25 @@ void TreeNode::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void TreeNode::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
- if (d_popupItem && d_popupItem->isVisible())
+ if (d_popupItem && d_popupItem->isVisible()) {
d_popupItem->setVisible(false);
+ event->accept();
+ }
}
void TreeNode::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
- if (d_popupItem && d_popupItem->isVisible())
- d_popupItem->setPos(event->scenePos());
+ if (d_popupItem && d_popupItem->isVisible()) {
+ if (event->screenPos() == event->lastScreenPos())
+ {
+ QRectF oldRect = d_popupItem->sceneBoundingRect();
+ d_popupItem->setPos(event->scenePos());
+ d_popupItem->scene()->invalidate(oldRect);
+ }
+ else
+ d_popupItem->setPos(event->scenePos());
+ event->accept();
+}
}
void TreeNode::setAttribute(QString const &name, QString const &value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment