maxLibQt
ScrollableMessageBox Class Reference

A simple message box with a large scrollable area (a QTextEdit ) for detailed text (including HTML formatting). More...

#include "ScrollableMessageBox.h"

Inherits QDialog.

Public Types

enum  CustomButton { ShowDetails = 0x01 }
 
- Public Types inherited from QDialog
enum  DialogCode
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 

Public Member Functions

 ScrollableMessageBox (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Dialog)
 
 ScrollableMessageBox (const QString &title, const QString &text=QString(), const QString &details=QString(), QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Dialog)
 
 ScrollableMessageBox (const QString &title, QMessageBox::Icon icon, const QString &text, const QString &details=QString(), QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Dialog)
 
 ScrollableMessageBox (QWidget *parent, const QString &title, const QString &text, const QString &details, int buttons, int defaultButtton=QDialogButtonBox::NoButton, Qt::WindowFlags f=Qt::Dialog)
 buttons and defaultButtton can be QDialogButtonBox::StandardButton or QMessageBox::StandardButton enum values, or the special ScrollableMessageBox::ShowDetails button value. More...
 
 ScrollableMessageBox (QWidget *parent, const QString &title, QMessageBox::Icon icon, const QString &text, const QString &details, int buttons, int defaultButtton=QDialogButtonBox::NoButton, Qt::WindowFlags f=Qt::Dialog)
 buttons and defaultButtton can be QDialogButtonBox::StandardButton or QMessageBox::StandardButton enum values, or the special ScrollableMessageBox::ShowDetails button value. More...
 
QDialogButtonBoxbuttonBox () const
 The dialog's button box. Buttons could be added/removed directly, and its signals can be connected to in order to determine which button was pressed, etc. More...
 
bool detailsButtonVisible () const
 Returns true if the "show details" button is shown, false otherwise. More...
 
bool detailsExpanded () const
 Returns true if the details text is currently visible, false otherwise. More...
 
QLabeliconLabel () const
 The QLabel which holds the icon. It is recommended to use setIcon() instead of setting the pixmap directly as that will also adjust the layout size properly. More...
 
QLabelpromptLabel ()
 The QLabel which holds a prompt shown just above the buttons. This is created lazily if needed. More...
 
QTextEdittextEdit () const
 The QTextEdit which holds the detailed text. It is recommended to use setDetailedText() instead of setting the text directly as that will also adjust the dialog size if necessary. More...
 
QLabeltextLabel () const
 The QLabel which holds the text. It is recommended to use setText() instead of setting the label text directly as that will also adjust the dialog size if necessary. More...
 
- Public Member Functions inherited from QDialog
 QDialog (QWidget *parent, Qt::WindowFlags f)
 
virtual ~QDialog ()
 
virtual void accept ()
 
void accepted ()
 
virtual void done (int r)
 
virtual int exec ()
 
QWidgetextension () const const
 
void finished (int result)
 
bool isSizeGripEnabled () const const
 
virtual const QMetaObjectmetaObject () const const
 
virtual QSize minimumSizeHint () const const override
 
virtual void open ()
 
Qt::Orientation orientation () const const
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
virtual void * qt_metacast (const char *)
 
virtual void reject ()
 
void rejected ()
 
int result () const const
 
void setExtension (QWidget *extension)
 
void setModal (bool modal)
 
void setOrientation (Qt::Orientation orientation)
 
void setResult (int i)
 
void setSizeGripEnabled (bool)
 
virtual void setVisible (bool visible) override
 
void showExtension (bool showIt)
 
virtual QSize sizeHint () const const override
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent, Qt::WindowFlags f)
 
virtual ~QWidget ()
 
bool acceptDrops () const const
 
QString accessibleDescription () const const
 
QString accessibleName () const const
 
QList< QAction * > actions () const const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (QList< QAction * > actions)
 
void adjustSize ()
 
bool autoFillBackground () const const
 
QPalette::ColorRole backgroundRole () const const
 
QBackingStorebackingStore () const const
 
QSize baseSize () const const
 
QWidgetchildAt (const QPoint &p) const const
 
QWidgetchildAt (int x, int y) const const
 
QRect childrenRect () const const
 
QRegion childrenRegion () const const
 
void clearFocus ()
 
void clearMask ()
 
bool close ()
 
QMargins contentsMargins () const const
 
QRect contentsRect () const const
 
Qt::ContextMenuPolicy contextMenuPolicy () const const
 
QCursor cursor () const const
 
void customContextMenuRequested (const QPoint &pos)
 
WId effectiveWinId () const const
 
void ensurePolished () const const
 
Qt::FocusPolicy focusPolicy () const const
 
QWidgetfocusProxy () const const
 
QWidgetfocusWidget () const const
 
const QFontfont () const const
 
QFontInfo fontInfo () const const
 
QFontMetrics fontMetrics () const const
 
QPalette::ColorRole foregroundRole () const const
 
QRect frameGeometry () const const
 
QSize frameSize () const const
 
const QRectgeometry () const const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const const
 
QPixmap grab (const QRect &rectangle)
 
void grabGesture (Qt::GestureType gesture, Qt::GestureFlags flags)
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context)
 
QGraphicsEffectgraphicsEffect () const const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const const
 
bool hasEditFocus () const const
 
bool hasFocus () const const
 
virtual bool hasHeightForWidth () const const
 
bool hasMouseTracking () const const
 
bool hasTabletTracking () const const
 
int height () const const
 
virtual int heightForWidth (int w) const const
 
void hide ()
 
Qt::InputMethodHints inputMethodHints () const const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const const
 
bool isAncestorOf (const QWidget *child) const const
 
bool isEnabled () const const
 
bool isEnabledTo (const QWidget *ancestor) const const
 
bool isEnabledToTLW () const const
 
bool isFullScreen () const const
 
bool isHidden () const const
 
bool isMaximized () const const
 
bool isMinimized () const const
 
bool isModal () const const
 
bool isTopLevel () const const
 
bool isVisible () const const
 
bool isVisibleTo (const QWidget *ancestor) const const
 
bool isWindow () const const
 
bool isWindowModified () const const
 
QLayoutlayout () const const
 
Qt::LayoutDirection layoutDirection () const const
 
QLocale locale () const const
 
void lower ()
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const const
 
QPoint mapFromGlobal (const QPoint &pos) const const
 
QPoint mapFromParent (const QPoint &pos) const const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const const
 
QPoint mapToGlobal (const QPoint &pos) const const
 
QPoint mapToParent (const QPoint &pos) const const
 
QRegion mask () const const
 
int maximumHeight () const const
 
QSize maximumSize () const const
 
int maximumWidth () const const
 
int minimumHeight () const const
 
QSize minimumSize () const const
 
int minimumWidth () const const
 
void move (int x, int y)
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const const
 
QWidgetnextInFocusChain () const const
 
QRect normalGeometry () const const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
virtual QPaintEnginepaintEngine () const const override
 
const QPalettepalette () const const
 
QWidgetparentWidget () const const
 
QPoint pos () const const
 
QWidgetpreviousInFocusChain () const const
 
void raise ()
 
QRect rect () const const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint ()
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &rgn)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &r)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool on)
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (int basew, int baseh)
 
void setBaseSize (const QSize &)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setDisabled (bool disable)
 
void setEditFocus (bool enable)
 
void setEnabled (bool)
 
void setFixedHeight (int h)
 
void setFixedSize (int w, int h)
 
void setFixedSize (const QSize &s)
 
void setFixedWidth (int w)
 
void setFocus ()
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *w)
 
void setFont (const QFont &)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setHidden (bool hidden)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void setShortcutAutoRepeat (int id, bool enable)
 
void setShortcutEnabled (int id, bool enable)
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setSizePolicy (QSizePolicy)
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *style)
 
void setStyleSheet (const QString &styleSheet)
 
void setTabletTracking (bool enable)
 
void setToolTip (const QString &)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlag (Qt::WindowType flag, bool on)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowModified (bool)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
void setWindowTitle (const QString &)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
QSize size () const const
 
QSize sizeIncrement () const const
 
QSizePolicy sizePolicy () const const
 
void stackUnder (QWidget *w)
 
QString statusTip () const const
 
QStylestyle () const const
 
QString styleSheet () const const
 
bool testAttribute (Qt::WidgetAttribute attribute) const const
 
QString toolTip () const const
 
int toolTipDuration () const const
 
QWidgettopLevelWidget () const const
 
bool underMouse () const const
 
void ungrabGesture (Qt::GestureType gesture)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update ()
 
void update (const QRegion &rgn)
 
void update (int x, int y, int w, int h)
 
void update (const QRect &rect)
 
void updateGeometry ()
 
bool updatesEnabled () const const
 
QRegion visibleRegion () const const
 
QString whatsThis () const const
 
int width () const const
 
QWidgetwindow () const const
 
QString windowFilePath () const const
 
Qt::WindowFlags windowFlags () const const
 
QWindowwindowHandle () const const
 
QIcon windowIcon () const const
 
void windowIconChanged (const QIcon &icon)
 
QString windowIconText () const const
 
void windowIconTextChanged (const QString &iconText)
 
Qt::WindowModality windowModality () const const
 
qreal windowOpacity () const const
 
QString windowRole () const const
 
Qt::WindowStates windowState () const const
 
QString windowTitle () const const
 
void windowTitleChanged (const QString &title)
 
Qt::WindowType windowType () const const
 
WId winId () const const
 
int x () const const
 
int y () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
const QObjectList & children () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const const
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const const
 
int depth () const const
 
int devicePixelRatio () const const
 
qreal devicePixelRatioF () const const
 
int height () const const
 
int heightMM () const const
 
int logicalDpiX () const const
 
int logicalDpiY () const const
 
bool paintingActive () const const
 
int physicalDpiX () const const
 
int physicalDpiY () const const
 
int width () const const
 
int widthMM () const const
 

Public Slots

void setDetailedText (const QString &details=QString(), Qt::TextFormat format=Qt::AutoText)
 Set the longer details text shown in the scrollable message pane area. More...
 
void setDetailsButtonVisible (bool visible=true, bool toggleDetails=true, bool toggleDetailPosition=true)
 Enables or disables showing a "show details" button which toggles visibility of the details text. More...
 
void setFontFixedWidth (bool fixed=true)
 Changes the font used to display the detailed text to a fixed-width or a proportional font based on fixed value. More...
 
void setIcon (const QPixmap &pixmap=QPixmap())
 Set the image displayed next to the message box text label to pixmap. An invalid pixmap value will remove any current icon. More...
 
void setIcon (QMessageBox::Icon icon, const QSize &size=QSize())
 Set the image displayed next to the message box text to a standard QMessageBox::Icon icon. More...
 
void setIcon (const QIcon &icon, const QSize &size=QSize())
 Set the image displayed next to the message box text to the specified icon. More...
 
void setIconAlignment (Qt::AlignmentFlag valign)
 Set the vertical alignment of the icon to valign. More...
 
void setPromptText (const QString &text=QString())
 Set a message to be shown just above the dialog button(s), below the details text. More...
 
void setShowDetailsBelowButtons (bool on=true)
 Toggles where the details text is displayed. More...
 
void setText (const QString &text=QString())
 Set the text shown at the top of the dialog, before the details text. More...
 
void setTextWordWrap (bool wrap=true)
 Enable or disable word wrapping for the text message (shorthand for textLabel()->setWordWrap(wrap) ). More...
 
void setWordWrap (bool wrap=true)
 Enable or disable word wrapping for the detailed text display. More...
 
bool showDetailsExpanded (bool on=true)
 Sets the details text visibility to on. More...
 
bool toggleDetailsExpanded ()
 Shows the details text if it is currently hidden, and hides it otherwise. More...
 
void updateSize ()
 Recalculates the dialog minimum size after UI element changes like adding/removing buttons. More...
 

Protected Member Functions

void showEvent (QShowEvent *e) override
 
- Protected Member Functions inherited from QDialog
virtual void closeEvent (QCloseEvent *e) override
 
virtual void contextMenuEvent (QContextMenuEvent *e) override
 
virtual bool eventFilter (QObject *o, QEvent *e) override
 
virtual void keyPressEvent (QKeyEvent *e) override
 
virtual void resizeEvent (QResizeEvent *) override
 
- Protected Member Functions inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void changeEvent (QEvent *event)
 
void create (WId window, bool initializeWindow, bool destroyOldWindow)
 
void destroy (bool destroyWindow, bool destroySubWindows)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
virtual bool event (QEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
virtual void initPainter (QPainter *painter) const const override
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
virtual int metric (QPaintDevice::PaintDeviceMetric m) const const override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void paintEvent (QPaintEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
void updateMicroFocus ()
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from QPaintDevice
 QPaintDevice ()
 

Additional Inherited Members

- Properties inherited from QDialog
 modal
 
 sizeGripEnabled
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 tabletTracking
 
 toolTip
 
 toolTipDuration
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QDialog
QString tr (const char *s, const char *c, int n)
 
QString trUtf8 (const char *s, const char *c, int n)
 
- Static Public Member Functions inherited from QWidget
QWidgetcreateWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags)
 
QWidgetfind (WId id)
 
QWidgetkeyboardGrabber ()
 
QWidgetmouseGrabber ()
 
void setTabOrder (QWidget *first, QWidget *second)
 
QString tr (const char *s, const char *c, int n)
 
QString trUtf8 (const char *s, const char *c, int n)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QDialog
 Accepted
 
 Rejected
 
- Public Attributes inherited from QWidget
 DrawChildren
 
 DrawWindowBackground
 
 IgnoreMask
 
typedef RenderFlags
 
- Public Attributes inherited from QPaintDevice
 PdmDepth
 
 PdmDevicePixelRatio
 
 PdmDevicePixelRatioScaled
 
 PdmDpiX
 
 PdmDpiY
 
 PdmHeight
 
 PdmHeightMM
 
 PdmNumColors
 
 PdmPhysicalDpiX
 
 PdmPhysicalDpiY
 
 PdmWidth
 
 PdmWidthMM
 

Detailed Description

A simple message box with a large scrollable area (a QTextEdit ) for detailed text (including HTML formatting).

Version
1.1.0

This is a message box dialog for presenting an amount of text which would not comfortably fit in a regular popup message dialog. It addresses the deficiencies found in QMessageBox with "informative" and/or "detailed" text options, namely its small and fixed size and lack of text formatting for those texts, despite what the documentation states, and forced bold font on the "text" label.

Basic usage is very similar to QMessageBox. You can set the dialog title, an optional short text message to show at the top, and the larger text block to show as the "details." By default there is only one "OK" button to dismiss the dialog. There is no separate "informative text" like in QMessageBox – instead just format the text message however you like, with line breaks/paragraphs, fonts, HTML, etc. In QMessageBox the "informative text" is simply displayed under the "text" anyway.

Since
1.1.0

An icon can be displayed next to the message text, like in a QMessageBox. Several setIcon() overloads are available, allowing custom icons, pixmaps, or the standard QMessageBox::Icon types. Setting an icon will also set the QWidget::windowIcon for the dialog. The icon can be reset to none by using the setIcon() method with no argument (this will reset the windowIcon back to default as well). There are two new constructor overloads available which can specify a standard icon at creation time.

An additional "prompt" label can be used to insert text just above the dialog buttons (for example an "Are you sure?" question). Use setPromptText() to set the text and and promptLabel() for direct access to the QLabel.

A "show details" button can be enabled for the user to toggle, and the details text visibility can be toggled programmatically. Also the details text can be shown below the buttons instead of above, which can be a better arrangement when the user can toggle them. See showDetailsExpanded(), toggleDetailsExpanded(), setShowDetailsBelowButtons(), and setDetailsButtonVisible() for more information.

Two new constructors which let you specify the default dialog button(s) are available. The button values for these can be QDialogButtonBox::StandardButton or QMessageBox::StandardButton enum values, or the special ScrollableMessageBox::ShowDetails button value which will enable the "show details" button described above.

When first shown, the dialog will try to esablish a reasonable size based on the contents of the QTextEdit. The dialog is also fully resizable.

Developers have direct access to the QTextEdit used for displaying the text, the QLabels used for the text message and prompt, and the QDialogButtonBox. There are a couple convenience functions for setting the font style and word wrap on the QTextEdit. By default a variable-width font is used with word-wrap on.

Definition at line 85 of file ScrollableMessageBox.h.

Member Enumeration Documentation

◆ CustomButton

Enumerator
ShowDetails 

A "Show Details" button which toggles the details text on and off (defined with QDialogButtonBox::ActionRole)

Definition at line 90 of file ScrollableMessageBox.h.

Constructor & Destructor Documentation

◆ ScrollableMessageBox() [1/5]

ScrollableMessageBox::ScrollableMessageBox ( QWidget parent = nullptr,
Qt::WindowFlags  f = Qt::Dialog 
)
explicit

Definition at line 124 of file ScrollableMessageBox.cpp.

◆ ScrollableMessageBox() [2/5]

ScrollableMessageBox::ScrollableMessageBox ( const QString title,
const QString text = QString(),
const QString details = QString(),
QWidget parent = nullptr,
Qt::WindowFlags  f = Qt::Dialog 
)
explicit

Definition at line 130 of file ScrollableMessageBox.cpp.

◆ ScrollableMessageBox() [3/5]

ScrollableMessageBox::ScrollableMessageBox ( const QString title,
QMessageBox::Icon  icon,
const QString text,
const QString details = QString(),
QWidget parent = nullptr,
Qt::WindowFlags  f = Qt::Dialog 
)
explicit
Since
1.1.0

Definition at line 136 of file ScrollableMessageBox.cpp.

◆ ScrollableMessageBox() [4/5]

ScrollableMessageBox::ScrollableMessageBox ( QWidget parent,
const QString title,
const QString text,
const QString details,
int  buttons,
int  defaultButtton = QDialogButtonBox::NoButton,
Qt::WindowFlags  f = Qt::Dialog 
)
explicit

buttons and defaultButtton can be QDialogButtonBox::StandardButton or QMessageBox::StandardButton enum values, or the special ScrollableMessageBox::ShowDetails button value.

buttons can be any OR'd combination of these flags.

Since
1.1.0

Definition at line 143 of file ScrollableMessageBox.cpp.

◆ ScrollableMessageBox() [5/5]

ScrollableMessageBox::ScrollableMessageBox ( QWidget parent,
const QString title,
QMessageBox::Icon  icon,
const QString text,
const QString details,
int  buttons,
int  defaultButtton = QDialogButtonBox::NoButton,
Qt::WindowFlags  f = Qt::Dialog 
)
explicit

buttons and defaultButtton can be QDialogButtonBox::StandardButton or QMessageBox::StandardButton enum values, or the special ScrollableMessageBox::ShowDetails button value.

buttons can be any OR'd combination of these flags.

Since
1.1.0

Definition at line 149 of file ScrollableMessageBox.cpp.

Member Function Documentation

◆ buttonBox()

QDialogButtonBox* ScrollableMessageBox::buttonBox ( ) const
inline

The dialog's button box. Buttons could be added/removed directly, and its signals can be connected to in order to determine which button was pressed, etc.

Definition at line 117 of file ScrollableMessageBox.h.

◆ detailsButtonVisible()

bool ScrollableMessageBox::detailsButtonVisible ( ) const

Returns true if the "show details" button is shown, false otherwise.

See also
setDetailsButtonVisible()
Since
1.1.0

Definition at line 306 of file ScrollableMessageBox.cpp.

◆ detailsExpanded()

bool ScrollableMessageBox::detailsExpanded ( ) const

Returns true if the details text is currently visible, false otherwise.

See also
showDetailsExpanded(), toggleDetailsExpanded(), setDetailsButtonVisible()
Since
1.1.0

Definition at line 276 of file ScrollableMessageBox.cpp.

◆ iconLabel()

QLabel* ScrollableMessageBox::iconLabel ( ) const
inline

The QLabel which holds the icon. It is recommended to use setIcon() instead of setting the pixmap directly as that will also adjust the layout size properly.

Definition at line 115 of file ScrollableMessageBox.h.

◆ promptLabel()

QLabel * ScrollableMessageBox::promptLabel ( )

The QLabel which holds a prompt shown just above the buttons. This is created lazily if needed.

See also
setPromptText()
Since
1.1.0

Definition at line 179 of file ScrollableMessageBox.cpp.

◆ setDetailedText

void ScrollableMessageBox::setDetailedText ( const QString details = QString(),
Qt::TextFormat  format = Qt::AutoText 
)
slot

Set the longer details text shown in the scrollable message pane area.

Definition at line 163 of file ScrollableMessageBox.cpp.

◆ setDetailsButtonVisible

void ScrollableMessageBox::setDetailsButtonVisible ( bool  visible = true,
bool  toggleDetails = true,
bool  toggleDetailPosition = true 
)
slot

Enables or disables showing a "show details" button which toggles visibility of the details text.

If toggleDetails is true (default) then the details text is hidden when visible is true and shown when visible is false. If toggleDetailPosition is true (default) then the details text is moved below the buttons when visible is true and above them when visible is false.

See also
showDetailsExpanded(), toggleDetailsExpanded(), setShowDetailsBelowButtons()
Since
1.1.0

Definition at line 311 of file ScrollableMessageBox.cpp.

◆ setFontFixedWidth

void ScrollableMessageBox::setFontFixedWidth ( bool  fixed = true)
slot

Changes the font used to display the detailed text to a fixed-width or a proportional font based on fixed value.

Definition at line 236 of file ScrollableMessageBox.cpp.

◆ setIcon [1/3]

void ScrollableMessageBox::setIcon ( const QPixmap pixmap = QPixmap())
slot

Set the image displayed next to the message box text label to pixmap. An invalid pixmap value will remove any current icon.

Since
1.1.0

Definition at line 206 of file ScrollableMessageBox.cpp.

◆ setIcon [2/3]

void ScrollableMessageBox::setIcon ( QMessageBox::Icon  icon,
const QSize size = QSize() 
)
slot

Set the image displayed next to the message box text to a standard QMessageBox::Icon icon.

You can optionally specify a size for the icon as well. The default size is style-specific.

Since
1.1.0

Definition at line 219 of file ScrollableMessageBox.cpp.

◆ setIcon [3/3]

void ScrollableMessageBox::setIcon ( const QIcon icon,
const QSize size = QSize() 
)
slot

Set the image displayed next to the message box text to the specified icon.

You can optionally specify a size for the icon as well. The default size is style-specific.

Since
1.1.0

Definition at line 224 of file ScrollableMessageBox.cpp.

◆ setIconAlignment

void ScrollableMessageBox::setIconAlignment ( Qt::AlignmentFlag  valign)
slot

Set the vertical alignment of the icon to valign.

The alignment is in relation to the text label and is only relevant if the text is taller than the icon. Can be one of: Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBotton. is Qt::AlignTop

See also
setIcon()
Since
1.1.0

Definition at line 229 of file ScrollableMessageBox.cpp.

◆ setPromptText

void ScrollableMessageBox::setPromptText ( const QString text = QString())
slot

Set a message to be shown just above the dialog button(s), below the details text.

Since
1.1.0

Definition at line 190 of file ScrollableMessageBox.cpp.

◆ setShowDetailsBelowButtons

void ScrollableMessageBox::setShowDetailsBelowButtons ( bool  on = true)
slot

Toggles where the details text is displayed.

Set on to true to display them below the buttons, or false to show them above the buttons (and above the label set with setPromptText()). Showing the details below the buttons may be more convenient for the user when the show/hide button is used because toggling it will not make the buttons move.

Since
1.1.0

Definition at line 338 of file ScrollableMessageBox.cpp.

◆ setText

void ScrollableMessageBox::setText ( const QString text = QString())
slot

Set the text shown at the top of the dialog, before the details text.

Definition at line 155 of file ScrollableMessageBox.cpp.

◆ setTextWordWrap

void ScrollableMessageBox::setTextWordWrap ( bool  wrap = true)
slot

Enable or disable word wrapping for the text message (shorthand for textLabel()->setWordWrap(wrap) ).

Since
1.1.0

Definition at line 266 of file ScrollableMessageBox.cpp.

◆ setWordWrap

void ScrollableMessageBox::setWordWrap ( bool  wrap = true)
slot

Enable or disable word wrapping for the detailed text display.

Definition at line 258 of file ScrollableMessageBox.cpp.

◆ showDetailsExpanded

bool ScrollableMessageBox::showDetailsExpanded ( bool  on = true)
slot

Sets the details text visibility to on.

See also
detailsExpanded(), toggleDetailsExpanded(), setDetailsButtonVisible()
Since
1.1.0

Definition at line 281 of file ScrollableMessageBox.cpp.

◆ showEvent()

void ScrollableMessageBox::showEvent ( QShowEvent e)
overrideprotectedvirtual

Reimplemented from QDialog.

Definition at line 459 of file ScrollableMessageBox.cpp.

◆ textEdit()

QTextEdit* ScrollableMessageBox::textEdit ( ) const
inline

The QTextEdit which holds the detailed text. It is recommended to use setDetailedText() instead of setting the text directly as that will also adjust the dialog size if necessary.

Definition at line 111 of file ScrollableMessageBox.h.

◆ textLabel()

QLabel* ScrollableMessageBox::textLabel ( ) const
inline

The QLabel which holds the text. It is recommended to use setText() instead of setting the label text directly as that will also adjust the dialog size if necessary.

Definition at line 113 of file ScrollableMessageBox.h.

◆ toggleDetailsExpanded

bool ScrollableMessageBox::toggleDetailsExpanded ( )
slot

Shows the details text if it is currently hidden, and hides it otherwise.

See also
showDetailsExpanded(), setDetailsButtonVisible()
Since
1.1.0

Definition at line 299 of file ScrollableMessageBox.cpp.

◆ updateSize

void ScrollableMessageBox::updateSize ( )
slot

Recalculates the dialog minimum size after UI element changes like adding/removing buttons.

Optionally call adjustSize() afterwards to update the dialog geometry to the updated sizeHint(). This method is called by all the built-in functions which may change the UI size. It is usually not necessary to call this method directly.

Definition at line 429 of file ScrollableMessageBox.cpp.