]> sigrok.org Git - pulseview.git/blobdiff - pv/widgets/popup.hpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / widgets / popup.hpp
index 84def1fe90eee3171a4914a0cc4157e47c85de5d..879c5f9d83542e3a4fc50485441554cabdc9ea24 100644 (file)
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef PULSEVIEW_PV_WIDGETS_POPUP_HPP
 #define PULSEVIEW_PV_WIDGETS_POPUP_HPP
 
+#include <QScrollArea>
 #include <QWidget>
 
 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
@@ -54,7 +71,7 @@ public:
 
        bool eventFilter(QObject *obj, QEvent *event);
 
-       void show();
+       virtual void show();
 
 private:
        bool space_for_arrow() const;