Qt 4.8
Classes | Macros
qmessagebox.h File Reference
#include <QtGui/qdialog.h>

Go to the source code of this file.

Classes

class  QMessageBox
 The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. More...
 

Macros

#define QT_REQUIRE_VERSION(argc, argv, str)
 

Macro Definition Documentation

◆ QT_REQUIRE_VERSION

#define QT_REQUIRE_VERSION (   argc,
  argv,
  str 
)
Value:
QString sq = QString::fromLatin1(qVersion()); \
if ((sq.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
(sq.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
sq.section(QChar::fromLatin1('.'),2,2).toInt()<(s.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
(s.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
s.section(QChar::fromLatin1('.'),2,2).toInt()) { \
if (!qApp){ \
new QApplication(argc,argv); \
} \
QString s = QApplication::tr("Executable '%1' requires Qt "\
"%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\
"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }}
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
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
QString qAppName()
Q_CORE_EXPORT const char * qVersion()
#define qApp
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a critical message box with the given title and text in front of the specified parent widget...
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
Definition: qchar.h:378
Q_CORE_EXPORT void qFatal(const char *,...)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

This macro can be used to ensure that the application is run against a recent enough version of Qt. This is especially useful if your application depends on a specific bug fix introduced in a bug-fix release (e.g., 4.0.2).

The argc and argv parameters are the main() function's argc and argv parameters. The version parameter is a string literal that specifies which version of Qt the application requires (e.g., "4.0.2").

Example:

#include <QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QT_REQUIRE_VERSION(argc, argv, "4.0.2")
QApplication app(argc, argv);
...
return app.exec();
}

Definition at line 344 of file qmessagebox.h.