X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fwidgets%2Fpopup.hpp;h=879c5f9d83542e3a4fc50485441554cabdc9ea24;hp=116dad50aad72a98000f306937bb1df9863e46d3;hb=HEAD;hpb=efdec55aec1a137460fa362a381ed1904182bfed diff --git a/pv/widgets/popup.hpp b/pv/widgets/popup.hpp index 116dad50..879c5f9d 100644 --- a/pv/widgets/popup.hpp +++ b/pv/widgets/popup.hpp @@ -20,11 +20,29 @@ #ifndef PULSEVIEW_PV_WIDGETS_POPUP_HPP #define PULSEVIEW_PV_WIDGETS_POPUP_HPP +#include #include namespace pv { namespace widgets { + +// A regular QScrollArea has a fixed size and provides scroll bars when the +// content can't be shown in its entirety. However, we want no horizontal +// scroll bar and want the scroll area to adjust its width to fit the content +// instead. +// Inspired by https://stackoverflow.com/questions/21253755/qscrollarea-with-dynamically-changing-contents?answertab=votes#tab-top +class QWidthAdjustingScrollArea : public QScrollArea +{ + Q_OBJECT + +public: + QWidthAdjustingScrollArea(QWidget* parent = nullptr); + void setWidget(QWidget* w); + bool eventFilter(QObject* obj, QEvent* ev); +}; + + class Popup : public QWidget { Q_OBJECT @@ -53,7 +71,7 @@ public: bool eventFilter(QObject *obj, QEvent *event); - void show(); + virtual void show(); private: bool space_for_arrow() const;