Участник:Root/Песочница
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Root (Обсуждение | вклад) |
Root (Обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
- | + | ==QApplication== | |
- | + | The [[Qt:Документация 4.3.2/qapplication | QApplication]] class has been split into two classes: [[Qt:Документация 4.3.2/qcoreapplication | QCoreApplication]] and [[Qt:Документация 4.3.2/qapplication | QApplication]]. The new [[Qt:Документация 4.3.2/qapplication | QApplication]] class inherits [[Qt:Документация 4.3.2/qcoreapplication | QCoreApplication]] and adds GUI-related functionality. In practice, this has no consequences for existing Qt applications. | |
- | + | In addition, the following API changes were made: | |
- | + | #[[Qt:Документация 4.3.2/qapplication#allWidgets | QApplication::allWidgets]]() and [[Qt:Документация 4.3.2/qapplication#topLevelWidgets | QApplication::topLevelWidgets]]() used to return a pointer to a [[Qt:Документация 4.3.2/qwidget#QWidgetList-typedef | QWidgetList]]. Now they return a [[Qt:Документация 4.3.2/qwidget#QWidgetList-typedef | QWidgetList]].<br />Also, [[Qt:Документация 4.3.2/qwidget#QWidgetList-typedef | QWidgetList]] has changed from being a typedef for QPtrList<[[Qt:Документация 4.3.2/qwidget | QWidget]]> to being a typedef for [[Qt:Документация 4.3.2/qlist | QList]]<[[Qt:Документация 4.3.2/qwidget | QWidget]] *>. See the [[#qwidgetlist-section | section on QWidgetList]] below for details.<br /><br />For example, if you have code like<br /><source lang="cpp-qt"> QWidgetList *list = QApplication::topLevelWidgets(); QWidgetListIt it(*list); QWidget *widget; while ((widget = it.current())) { if (widget->inherits("MainWindow")) ((MainWindow *)widget)->updateRecentFileItems(); ++it; } delete list;</source> <br />you can rewrite it as<br /><source lang="cpp-qt"> QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { if (MainWindow *mainWin = qobject_cast<MainWindow>(list.at(i))) mainWin->updateRecentFileItems(); }</source> | |
- | + | #[[Qt:Документация 4.3.2/qapplication-qt3#setMainWidget | QApplication::setMainWidget]]() is no longer used. When all an application's windows are closed, the application will exit normally. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | < | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + |
Версия 13:10, 6 ноября 2008
QApplication
The QApplication class has been split into two classes: QCoreApplication and QApplication. The new QApplication class inherits QCoreApplication and adds GUI-related functionality. In practice, this has no consequences for existing Qt applications.
In addition, the following API changes were made:
- QApplication::allWidgets() and QApplication::topLevelWidgets() used to return a pointer to a QWidgetList. Now they return a QWidgetList.
Also, QWidgetList has changed from being a typedef for QPtrList< QWidget> to being a typedef for QList< QWidget *>. See the section on QWidgetList below for details.
For example, if you have code likeQWidgetList *list = QApplication::topLevelWidgets(); QWidgetListIt it(*list); QWidget *widget; while ((widget = it.current())) { if (widget->inherits("MainWindow")) ((MainWindow *)widget)->updateRecentFileItems(); ++it; } delete list;
you can rewrite it asQWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { if (MainWindow *mainWin = qobject_cast<MainWindow>(list.at(i))) mainWin->updateRecentFileItems(); }
- QApplication::setMainWidget() is no longer used. When all an application's windows are closed, the application will exit normally.