MyTetra Share
Делитесь знаниями!
Qt: Как узнать все методы объекта во время выполнения программы
Время создания: 20.03.2016 22:41
Раздел: Компьютер - Программирование - Язык C++ (Си++) - Библиотека Qt - Принципы написания кода
Запись: xintrea/mytetra_syncro/master/base/1413927770ewuon8i8os/text.html на raw.github.com

В Qt можно распечатать список методов, поддерживаемых объектом, причем сделать это "на лету", во время выполнения программы.


Пример кода:


int i,n = qApp->staticMetaObject.methodCount();

for(i=0;i<n;i++)

qDebug() << "App method" << i << qApp->staticMetaObject.method(i).methodSignature();


Данный код выводит список методов объекта приложения. Вывод будет примерно таким:


01:34:23 [DBG] App method 0 "destroyed(QObject*)"

01:34:23 [DBG] App method 1 "destroyed()"

01:34:23 [DBG] App method 2 "objectNameChanged(QString)"

01:34:23 [DBG] App method 3 "deleteLater()"

01:34:23 [DBG] App method 4 "_q_reregisterTimers(void*)"

01:34:23 [DBG] App method 5 "aboutToQuit()"

01:34:23 [DBG] App method 6 "organizationNameChanged()"

01:34:23 [DBG] App method 7 "organizationDomainChanged()"

01:34:23 [DBG] App method 8 "applicationNameChanged()"

01:34:23 [DBG] App method 9 "applicationVersionChanged()"

01:34:23 [DBG] App method 10 "quit()"

01:34:23 [DBG] App method 11 "fontDatabaseChanged()"

01:34:23 [DBG] App method 12 "screenAdded(QScreen*)"

01:34:23 [DBG] App method 13 "lastWindowClosed()"

01:34:23 [DBG] App method 14 "focusObjectChanged(QObject*)"

01:34:23 [DBG] App method 15 "focusWindowChanged(QWindow*)"

01:34:23 [DBG] App method 16 "applicationStateChanged(Qt::ApplicationState)"

01:34:23 [DBG] App method 17 "commitDataRequest(QSessionManager&)"

01:34:23 [DBG] App method 18 "saveStateRequest(QSessionManager&)"

01:34:23 [DBG] App method 19 "_q_updateFocusObject(QObject*)"

01:34:23 [DBG] App method 20 "focusChanged(QWidget*,QWidget*)"

01:34:23 [DBG] App method 21 "setStyleSheet(QString)"

01:34:23 [DBG] App method 22 "setAutoSipEnabled(bool)"

01:34:23 [DBG] App method 23 "autoSipEnabled()"

01:34:23 [DBG] App method 24 "closeAllWindows()"

01:34:23 [DBG] App method 25 "aboutQt()"


Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования