Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QMessageBoxPrivate Class Reference
Inheritance diagram for QMessageBoxPrivate:
QDialogPrivate QWidgetPrivate QObjectPrivate QObjectData

Public Functions

void _q_buttonClicked (QAbstractButton *)
 
QAbstractButtonabstractButtonForId (int id) const
 
void addOldButtons (int button0, int button1, int button2)
 
void detectEscapeButton ()
 
int execReturnCode (QAbstractButton *button)
 
QAbstractButtonfindButton (int button0, int button1, int button2, int flags)
 
void hideSpecial ()
 Hides special buttons which are rather shown in the title bar on WinCE, to conserve screen space. More...
 
void init (const QString &title=QString(), const QString &text=QString())
 
int layoutMinimumWidth ()
 
 QMessageBoxPrivate ()
 
void retranslateStrings ()
 
void updateSize ()
 
- Public Functions inherited from QDialogPrivate
void hideDefault ()
 Hides the default button indicator. More...
 
virtual void mac_nativeDialogModalHelp ()
 
 QDialogPrivate ()
 
void resetModalitySetByOpen ()
 
void setDefault (QPushButton *)
 This function is called by the push button pushButton when it becomes the default button. More...
 
void setMainDefault (QPushButton *)
 This function sets the default default push button to pushButton. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QMessageBox::StandardButton showNewMessageBox (QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
 
static int showOldMessageBox (QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2)
 
static int showOldMessageBox (QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text, const QString &button2Text, int defaultButtonNumber, int escapeButtonNumber)
 
static QPixmap standardIcon (QMessageBox::Icon icon, QMessageBox *mb)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool autoAddOkButton
 
QDialogButtonBoxbuttonBox
 
QAbstractButtonclickedButton
 
bool compatMode
 
QList< QAbstractButton * > customButtonList
 
QPushButtondefaultButton
 
DetailButtondetailsButton
 
QMessageBoxDetailsTextdetailsText
 
QAbstractButtondetectedEscapeButton
 
QAbstractButtonescapeButton
 
QMessageBox::Icon icon
 
QLabeliconLabel
 
QLabelinformativeLabel
 
QLabellabel
 
QByteArray memberToDisconnectOnClose
 
QPointer< QObjectreceiverToDisconnectOnClose
 
QByteArray signalToDisconnectOnClose
 
- Public Variables inherited from QDialogPrivate
bool doShowExtension
 
QPointer< QEventLoopeventLoop
 
QWidgetextension
 
QPoint lastRMBPress
 
QPointer< QPushButtonmainDef
 
QSize max
 
QSize min
 
Qt::Orientation orientation
 
int rescode
 
int resetModalityTo
 
QSizeGripresizer
 
QSize size
 
bool sizeGripEnabled
 
bool wasModalitySet
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 163 of file qmessagebox.cpp.

Constructors and Destructors

◆ QMessageBoxPrivate()

QMessageBoxPrivate::QMessageBoxPrivate ( )
inline

Definition at line 168 of file qmessagebox.cpp.

169 #ifndef QT_NO_TEXTEDIT
170  detailsText(0),
171 #endif
172  compatMode(false), autoAddOkButton(true),
QMessageBoxDetailsText * detailsText
DetailButton * detailsButton
QPushButton * defaultButton
QAbstractButton * detectedEscapeButton
QLabel * informativeLabel
QAbstractButton * clickedButton
QAbstractButton * escapeButton

Functions

◆ _q_buttonClicked()

void QMessageBoxPrivate::_q_buttonClicked ( QAbstractButton button)

Definition at line 473 of file qmessagebox.cpp.

474 {
475  Q_Q(QMessageBox);
476 #ifndef QT_NO_TEXTEDIT
477  if (detailsButton && detailsText && button == detailsButton) {
480  updateSize();
481  } else
482 #endif
483  {
484  clickedButton = button;
485  q->done(execReturnCode(button)); // does not trigger closeEvent
486  emit q->buttonClicked(button);
487 
492  }
495  }
496 }
QPointer< QObject > receiverToDisconnectOnClose
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
QMessageBoxDetailsText * detailsText
DetailButton * detailsButton
QByteArray signalToDisconnectOnClose
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
int execReturnCode(QAbstractButton *button)
#define emit
Definition: qobjectdefs.h:76
void setHidden(bool hidden)
Convenience function, equivalent to setVisible(!hidden).
Definition: qwidget.h:495
void setLabel(DetailButtonLabel lbl)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QByteArray memberToDisconnectOnClose
QAbstractButton * clickedButton
void clear()
Clears the contents of the byte array and makes it empty.

◆ abstractButtonForId()

QAbstractButton * QMessageBoxPrivate::abstractButtonForId ( int  id) const

Definition at line 1985 of file qmessagebox.cpp.

1986 {
1987  Q_Q(const QMessageBox);
1988  QAbstractButton *result = customButtonList.value(id);
1989  if (result)
1990  return result;
1991  if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
1992  return 0;
1993  return q->button(newButton(id));
1994 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
static QMessageBox::StandardButton newButton(int button)
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QList< QAbstractButton * > customButtonList

◆ addOldButtons()

void QMessageBoxPrivate::addOldButtons ( int  button0,
int  button1,
int  button2 
)

Definition at line 1973 of file qmessagebox.cpp.

1974 {
1975  Q_Q(QMessageBox);
1976  q->addButton(newButton(button0));
1977  q->addButton(newButton(button1));
1978  q->addButton(newButton(button2));
1979  q->setDefaultButton(
1980  static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));
1981  q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
1982  compatMode = detectedCompat(button0, button1, button2);
1983 }
static QMessageBox::StandardButton newButton(int button)
QAbstractButton * findButton(int button0, int button1, int button2, int flags)
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
static bool detectedCompat(int button0, int button1, int button2)

◆ detectEscapeButton()

void QMessageBoxPrivate::detectEscapeButton ( )

Definition at line 1034 of file qmessagebox.cpp.

1035 {
1036  if (escapeButton) { // escape button explicitly set
1038  return;
1039  }
1040 
1041  // Cancel button automatically becomes escape button
1044  return;
1045 
1046  // If there is only one button, make it the escape button
1048  if (buttons.count() == 1) {
1049  detectedEscapeButton = buttons.first();
1050  return;
1051  }
1052 
1053  // if the message box has one RejectRole button, make it the escape button
1054  for (int i = 0; i < buttons.count(); i++) {
1055  if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::RejectRole) {
1056  if (detectedEscapeButton) { // already detected!
1058  break;
1059  }
1060  detectedEscapeButton = buttons.at(i);
1061  }
1062  }
1064  return;
1065 
1066  // if the message box has one NoRole button, make it the escape button
1067  for (int i = 0; i < buttons.count(); i++) {
1068  if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::NoRole) {
1069  if (detectedEscapeButton) { // already detected!
1071  break;
1072  }
1073  detectedEscapeButton = buttons.at(i);
1074  }
1075  }
1076 }
static Qt::MouseButtons buttons
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QAbstractButton * detectedEscapeButton
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
ButtonRole buttonRole(QAbstractButton *button) const
Returns the button role for the specified button.
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QList< QAbstractButton * > buttons() const
Returns a list of all the buttons that have been added to the button box.
QDialogButtonBox * buttonBox
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QAbstractButton * escapeButton

◆ execReturnCode()

int QMessageBoxPrivate::execReturnCode ( QAbstractButton button)

Definition at line 462 of file qmessagebox.cpp.

463 {
464  int ret = buttonBox->standardButton(button);
465  if (ret == QMessageBox::NoButton) {
466  ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1
467  } else if (compatMode) {
468  ret = oldButton(ret);
469  }
470  return ret;
471 }
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
static int oldButton(int button)
StandardButton standardButton(QAbstractButton *button) const
Returns the standard button enum value corresponding to the given button, or NoButton if the given bu...
QList< QAbstractButton * > customButtonList
QDialogButtonBox * buttonBox

◆ findButton()

QAbstractButton * QMessageBoxPrivate::findButton ( int  button0,
int  button1,
int  button2,
int  flags 
)

Definition at line 1958 of file qmessagebox.cpp.

1959 {
1960  Q_Q(QMessageBox);
1961  int button = 0;
1962 
1963  if (button0 & flags) {
1964  button = button0;
1965  } else if (button1 & flags) {
1966  button = button1;
1967  } else if (button2 & flags) {
1968  button = button2;
1969  }
1970  return q->button(newButton(button));
1971 }
static QMessageBox::StandardButton newButton(int button)
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ hideSpecial()

void QMessageBoxPrivate::hideSpecial ( )

Hides special buttons which are rather shown in the title bar on WinCE, to conserve screen space.

Warning
This function is not part of the public interface.

Definition at line 422 of file qmessagebox.cpp.

423 {
424  Q_Q(QMessageBox);
425  QList<QPushButton*> list = q->findChildren<QPushButton*>();
426  for (int i=0; i<list.size(); ++i) {
427  QPushButton *pb = list.at(i);
428  QString text = pb->text();
429  text.remove(QChar::fromLatin1('&'));
430  if (text == QApplication::translate("QMessageBox", "OK" ))
431  pb->setFixedSize(0,0);
432  }
433 }
QString text() const
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
Definition: qchar.h:378
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition: qwidget.cpp:4284
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
#define text
Definition: qobjectdefs.h:80
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ init()

void QMessageBoxPrivate::init ( const QString title = QString(),
const QString text = QString() 
)

Definition at line 234 of file qmessagebox.cpp.

235 {
236  Q_Q(QMessageBox);
237 
238  label = new QLabel;
239  label->setObjectName(QLatin1String("qt_msgbox_label"));
240  label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
243 #if defined(Q_WS_MAC)
244  label->setContentsMargins(16, 0, 0, 0);
245 #elif !defined(Q_WS_QWS)
246  label->setContentsMargins(2, 0, 0, 0);
247  label->setIndent(9);
248 #endif
250  iconLabel = new QLabel;
251  iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label"));
253 
255  buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));
256  buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));
259 
260  QGridLayout *grid = new QGridLayout;
261 #ifndef Q_WS_MAC
262 #ifdef Q_WS_S60
263  const int preferredIconColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 1 : 0;
264  const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1;
265 #else
266  const int preferredIconColumn = 0;
267  const int preferredTextColumn = 1;
268 #endif
269  grid->addWidget(iconLabel, 0, preferredIconColumn, 2, 1, Qt::AlignTop);
270  grid->addWidget(label, 0, preferredTextColumn, 1, 1);
271  // -- leave space for information label --
272  grid->addWidget(buttonBox, 2, 0, 1, 2);
273 #else
274  grid->setMargin(0);
275  grid->setVerticalSpacing(8);
276  grid->setHorizontalSpacing(0);
277  q->setContentsMargins(24, 15, 24, 20);
278  grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignLeft);
279  grid->addWidget(label, 0, 1, 1, 1);
280  // -- leave space for information label --
281  grid->setRowStretch(1, 100);
282  grid->setRowMinimumHeight(2, 6);
283  grid->addWidget(buttonBox, 3, 1, 1, 1);
284 #endif
285 
287  q->setLayout(grid);
288 
289  if (!title.isEmpty() || !text.isEmpty()) {
290  q->setWindowTitle(title);
291  q->setText(text);
292  }
293  q->setModal(true);
294 
295 #ifdef Q_WS_MAC
296  QFont f = q->font();
297  f.setBold(true);
298  label->setFont(f);
299 #endif
301 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
static Qt::LayoutDirection layoutDirection()
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
#define SLOT(a)
Definition: qobjectdefs.h:226
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
Definition: qlabel.cpp:820
void setOpenExternalLinks(bool open)
Definition: qlabel.cpp:797
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
void setHorizontalSpacing(int spacing)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
void setVerticalSpacing(int spacing)
void _q_buttonClicked(QAbstractButton *)
void setCenterButtons(bool center)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
QMessageBox::Icon icon
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
void setSizeConstraint(SizeConstraint)
Definition: qlayout.cpp:1435
void setRowStretch(int row, int stretch)
Sets the stretch factor of row row to stretch.
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qgridlayout.h:116
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
void setMargin(int)
Definition: qlayout.cpp:464
void setAlignment(Qt::Alignment)
Without this function, a call to e.
Definition: qlabel.cpp:532
QDialogButtonBox * buttonBox
void setIndent(int)
Definition: qlabel.cpp:620

◆ layoutMinimumWidth()

int QMessageBoxPrivate::layoutMinimumWidth ( )

Definition at line 303 of file qmessagebox.cpp.

304 {
305  layout->activate();
306  return layout->totalMinimumSize().width();
307 }
QLayout * layout
Definition: qwidget_p.h:704
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition: qlayout.cpp:1249
int width() const
Returns the width.
Definition: qsize.h:126
QSize totalMinimumSize() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:848

◆ retranslateStrings()

void QMessageBoxPrivate::retranslateStrings ( )

Definition at line 2030 of file qmessagebox.cpp.

2031 {
2032 #ifndef QT_NO_TEXTEDIT
2033  if (detailsButton)
2035 #endif
2036 }
QMessageBoxDetailsText * detailsText
DetailButton * detailsButton
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void setLabel(DetailButtonLabel lbl)

◆ showNewMessageBox()

static QMessageBox::StandardButton QMessageBoxPrivate::showNewMessageBox ( QWidget parent,
QMessageBox::Icon  icon,
const QString title,
const QString text,
QMessageBox::StandardButtons  buttons,
QMessageBox::StandardButton  defaultButton 
)
static

◆ showOldMessageBox() [1/2]

int QMessageBoxPrivate::showOldMessageBox ( QWidget parent,
QMessageBox::Icon  icon,
const QString title,
const QString text,
int  button0,
int  button1,
int  button2 
)
static

Definition at line 1996 of file qmessagebox.cpp.

Referenced by QMessageBox::critical(), QMessageBox::information(), QMessageBox::question(), showNewMessageBox(), and QMessageBox::warning().

1999 {
2000  QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
2001  messageBox.d_func()->addOldButtons(button0, button1, button2);
2002  return messageBox.exec();
2003 }
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
QMessageBox::Icon icon

◆ showOldMessageBox() [2/2]

int QMessageBoxPrivate::showOldMessageBox ( QWidget parent,
QMessageBox::Icon  icon,
const QString title,
const QString text,
const QString button0Text,
const QString button1Text,
const QString button2Text,
int  defaultButtonNumber,
int  escapeButtonNumber 
)
static

Definition at line 2005 of file qmessagebox.cpp.

2012 {
2013  QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
2014  QString myButton0Text = button0Text;
2015  if (myButton0Text.isEmpty())
2016  myButton0Text = QDialogButtonBox::tr("OK");
2017  messageBox.addButton(myButton0Text, QMessageBox::ActionRole);
2018  if (!button1Text.isEmpty())
2019  messageBox.addButton(button1Text, QMessageBox::ActionRole);
2020  if (!button2Text.isEmpty())
2021  messageBox.addButton(button2Text, QMessageBox::ActionRole);
2022 
2023  const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;
2024  messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));
2025  messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
2026 
2027  return messageBox.exec();
2028 }
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QMessageBox::Icon icon
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ standardIcon()

QPixmap QMessageBoxPrivate::standardIcon ( QMessageBox::Icon  icon,
QMessageBox mb 
)
static

Definition at line 2803 of file qmessagebox.cpp.

Referenced by QMessageBox::setIcon(), and QMessageBox::standardIcon().

2804 {
2805  QStyle *style = mb ? mb->style() : QApplication::style();
2806  int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);
2807  QIcon tmpIcon;
2808  switch (icon) {
2810  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);
2811  break;
2812  case QMessageBox::Warning:
2813  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);
2814  break;
2815  case QMessageBox::Critical:
2816  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);
2817  break;
2818  case QMessageBox::Question:
2819  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);
2820  default:
2821  break;
2822  }
2823  if (!tmpIcon.isNull())
2824  return tmpIcon.pixmap(iconSize, iconSize);
2825  return QPixmap();
2826 }
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
static QStyle * style()
Returns the application&#39;s style object.
QStyle * style() const
Definition: qwidget.cpp:2742
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
QMessageBox::Icon icon
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ updateSize()

void QMessageBoxPrivate::updateSize ( )

Definition at line 309 of file qmessagebox.cpp.

310 {
311  Q_Q(QMessageBox);
312 
313  if (!q->isVisible())
314  return;
315 
317 #if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
318  // the width of the screen, less the window border.
319  int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
320 #else
321  int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
322  // on small screens allows the messagebox be the same size as the screen
323  if (screenSize.width() <= 1024)
324  hardLimit = screenSize.width();
325 #endif
326 #ifdef Q_WS_MAC
327  int softLimit = qMin(screenSize.width()/2, 420);
328 #elif defined(Q_WS_QWS)
329  int softLimit = qMin(hardLimit, 500);
330 #else
331  // note: ideally on windows, hard and soft limits but it breaks compat
332 #ifndef Q_WS_WINCE
333  int softLimit = qMin(screenSize.width()/2, 500);
334 #else
335  int softLimit = qMin(screenSize.width() * 3 / 4, 500);
336 #endif //Q_WS_WINCE
337 #endif
338 
339  if (informativeLabel)
341 
342  label->setWordWrap(false); // makes the label return min size
343  int width = layoutMinimumWidth();
344 
345  if (width > softLimit) {
346  label->setWordWrap(true);
347  width = qMax(softLimit, layoutMinimumWidth());
348 
349  if (width > hardLimit) {
350  label->d_func()->ensureTextControl();
351  if (QTextControl *control = label->d_func()->control) {
352  QTextOption opt = control->document()->defaultTextOption();
354  control->document()->setDefaultTextOption(opt);
355  }
356  width = hardLimit;
357  }
358  }
359 #ifdef Q_WS_S60
360  // in S60 portait messageBoxes should always occupy maximum width
361  if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
362  width = hardLimit;
363  } else {
364  // in landscape the messageBoxes should be of same width as in portrait
365  width = qMin(QApplication::desktop()->size().height(), hardLimit);
366  }
367 #endif
368 
369  if (informativeLabel) {
372  policy.setHeightForWidth(true);
374  width = qMax(width, layoutMinimumWidth());
375  if (width > hardLimit) { // longest word is really big, so wrap anywhere
376  informativeLabel->d_func()->ensureTextControl();
377  if (QTextControl *control = informativeLabel->d_func()->control) {
378  QTextOption opt = control->document()->defaultTextOption();
380  control->document()->setDefaultTextOption(opt);
381  }
382  width = hardLimit;
383  }
384  policy.setHeightForWidth(label->wordWrap());
385  label->setSizePolicy(policy);
386  }
387 
388  QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
389  int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
390  if (windowTitleWidth > width)
391  width = windowTitleWidth;
392 
393  layout->activate();
394  int height = (layout->hasHeightForWidth())
395  ? layout->totalHeightForWidth(width)
397 
398 #ifndef QT_NO_STYLE_S60
399  QS60Style *s60Style = 0;
400  s60Style = qobject_cast<QS60Style *>(QApplication::style());
401 
402  //use custom pixel metric to deduce the minimum height of the messagebox
403  if (s60Style)
404  height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight));
405 #endif
406 
407  q->setFixedSize(width, height);
409 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
int totalHeightForWidth(int w) const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:823
bool wordWrap
the label&#39;s word-wrapping policy
Definition: qlabel.h:63
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setWordWrap(bool on)
Definition: qlabel.cpp:579
QLayout * layout
Definition: qwidget_p.h:704
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition: qlayout.cpp:1249
static QStyle * style()
Returns the application&#39;s style object.
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
static QFont font()
Returns the default application font.
int width() const
Returns the width.
Definition: qsize.h:126
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
QLabel * informativeLabel
int height() const
Returns the height.
Definition: qsize.h:129
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
QSize totalMinimumSize() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:848
void setWrapMode(WrapMode wrap)
Sets the option&#39;s text wrap mode to the given mode.
Definition: qtextoption.h:109
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
const QRect availableGeometry(int screen=-1) const
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

Properties

◆ autoAddOkButton

bool QMessageBoxPrivate::autoAddOkButton

Definition at line 223 of file qmessagebox.cpp.

◆ buttonBox

QDialogButtonBox* QMessageBoxPrivate::buttonBox

Definition at line 213 of file qmessagebox.cpp.

◆ clickedButton

QAbstractButton* QMessageBoxPrivate::clickedButton

Definition at line 217 of file qmessagebox.cpp.

◆ compatMode

bool QMessageBoxPrivate::compatMode

Definition at line 222 of file qmessagebox.cpp.

◆ customButtonList

QList<QAbstractButton *> QMessageBoxPrivate::customButtonList

Definition at line 214 of file qmessagebox.cpp.

◆ defaultButton

QPushButton* QMessageBoxPrivate::defaultButton

Definition at line 216 of file qmessagebox.cpp.

◆ detailsButton

DetailButton* QMessageBoxPrivate::detailsButton

Definition at line 218 of file qmessagebox.cpp.

◆ detailsText

QMessageBoxDetailsText* QMessageBoxPrivate::detailsText

Definition at line 220 of file qmessagebox.cpp.

◆ detectedEscapeButton

QAbstractButton* QMessageBoxPrivate::detectedEscapeButton

Definition at line 224 of file qmessagebox.cpp.

◆ escapeButton

QAbstractButton* QMessageBoxPrivate::escapeButton

Definition at line 215 of file qmessagebox.cpp.

◆ icon

QMessageBox::Icon QMessageBoxPrivate::icon

Definition at line 211 of file qmessagebox.cpp.

◆ iconLabel

QLabel* QMessageBoxPrivate::iconLabel

Definition at line 212 of file qmessagebox.cpp.

◆ informativeLabel

QLabel* QMessageBoxPrivate::informativeLabel

Definition at line 225 of file qmessagebox.cpp.

◆ label

QLabel* QMessageBoxPrivate::label

Definition at line 210 of file qmessagebox.cpp.

◆ memberToDisconnectOnClose

QByteArray QMessageBoxPrivate::memberToDisconnectOnClose

Definition at line 230 of file qmessagebox.cpp.

◆ receiverToDisconnectOnClose

QPointer<QObject> QMessageBoxPrivate::receiverToDisconnectOnClose

Definition at line 229 of file qmessagebox.cpp.

◆ signalToDisconnectOnClose

QByteArray QMessageBoxPrivate::signalToDisconnectOnClose

Definition at line 231 of file qmessagebox.cpp.


The documentation for this class was generated from the following file: