Участник:Root/Песочница

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

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:

  1. 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 like
         QWidgetList *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 as
         QWidgetList list = QApplication::topLevelWidgets();     for (int i = 0; i < list.size(); ++i) {         if (MainWindow *mainWin = qobject_cast<MainWindow>(list.at(i)))             mainWin->updateRecentFileItems();     }
  2. QApplication::setMainWidget() is no longer used. When all an application's windows are closed, the application will exit normally.

Вариант

  • какой-то текст
          код строка 1
          код строка 2
       
  • еще какой-то текст
          код строка 1
          код строка 2