]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/ruler.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / views / trace / ruler.cpp
index 555794fc42c6e881c5691fc1d64c43a0355e7cd3..64581459593a1fcc8148a4c4d2e14dee31164b64 100644 (file)
@@ -242,7 +242,11 @@ shared_ptr<ViewItem> Ruler::get_mouse_over_item(const QPoint &pt)
 
 void Ruler::mouseDoubleClickEvent(QMouseEvent *event)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+       hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(event->pos().x()));
+#else
        hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(event->x()));
+#endif
 }
 
 void Ruler::paintEvent(QPaintEvent*)
@@ -283,7 +287,7 @@ void Ruler::paintEvent(QPaintEvent*)
                const int rightedge = width();
                const int x_tick = tick.first;
                if ((x_tick > leftedge) && (x_tick < rightedge)) {
-                       const int x_left_bound = QFontMetrics(font()).width(tick.second) / 2;
+                       const int x_left_bound = util::text_width(QFontMetrics(font()), tick.second) / 2;
                        const int x_right_bound = rightedge - x_left_bound;
                        const int x_legend = min(max(x_tick, x_left_bound), x_right_bound);
                        p.drawText(x_legend, ValueMargin, 0, text_height,