QT6 源(6):QMetaObject::cast()、QObect :: qt_metacast()、qobject_cast<T>()的区别,前者由程序员使用,后者由 QT 的设计者使用

(1)

在这里插入图片描述
++

在这里插入图片描述

(2)

在这里插入图片描述

++

在这里插入图片描述

++

在这里插入图片描述

++

在这里插入图片描述

(3)

谢谢

仅仅把下面代码改成c++较低标准#include<mainwindow.h> #include <QtCore/qmetatype.h> #include <QtCore/qtmochelpers.h> #include <memory> #include <QtCore/qxptype_traits.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'MainWindow.hpp' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 69 #error "This file was generated using the moc from 6.9.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif #ifndef Q_CONSTINIT #define Q_CONSTINIT #endif QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_GCC("-Wuseless-cast") namespace { struct qt_meta_tag_ZN10MainWindowE_t {}; } // unnamed namespace template <> constexpr inline auto#w::qt_create_metaobjectdata<qt_meta_tag_ZN10MainWindowE_t>() { namespace QMC = QtMocConstants; QtMocHelpers::StringRefStorage qt_stringData { "MainWindow" }; QtMocHelpers::UintData qt_methods { }; QtMocHelpers::UintData qt_properties { }; QtMocHelpers::UintData qt_enums { }; return QtMocHelpers::metaObjectData<MainWindow, qt_meta_tag_ZN10MainWindowE_t>(QMC::MetaObjectFlag{}, qt_stringData, qt_methods, qt_properties, qt_enums); } Q_CONSTINIT const QMetaObject MainWindow::staticMetaObject = { { QMetaObject::SuperData::link<QMainWindow::staticMetaObject>(), qt_staticMetaObjectStaticContent<qt_meta_tag_ZN10MainWindowE_t>.stringdata, qt_staticMetaObjectStaticContent<qt_meta_tag_ZN10MainWindowE_t>.data, qt_static_metacall, nullptr, qt_staticMetaObjectRelocatingContent<qt_meta_tag_ZN10MainWindowE_t>.metaTypes, nullptr } }; void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { auto *_t = static_cast<MainWindow *>(_o); (void)_t; (void)_c; (void)_id; (void)_a; } const QMetaObject *MainWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MainWindow::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_staticMetaObjectStaticContent<qt_meta_tag_ZN10MainWindowE_t>.strings)) return static_cast<void*>(this); return QMainWindow::qt_metacast(_clname); } int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); return _id; } QT_WARNING_POP
最新发布
10-10
void FloorDet::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast<FloorDet *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->openCam(); break; case 1: _t->destroyCam(); break; case 2: _t->startCam(); break; case 3: _t->startcam(); break; case 4: _t->softCam(); break; case 5: _t->SendLog2((*reinterpret_cast< QString(*)>(_a[1]))); break; case 6: _t->sendtoolsA((*reinterpret_cast< cv::Mat(*)>(_a[1])),(*reinterpret_cast< cv::Mat(*)>(_a[2]))); break; case 7: _t->sendtoolsB((*reinterpret_cast< cv::Mat(*)>(_a[1])),(*reinterpret_cast< cv::Mat(*)>(_a[2]))); break; case 8: _t->chufa(); break; case 9: _t->cfclearD(); break; case 10: _t->pictureA11(); break; case 11: _t->pictureA12(); break; case 12: _t->pictureB1(); break; case 13: _t->pictureB2(); break; case 14: _t->pictureB3(); break; case 15: _t->XSzs_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 16: _t->XSng_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 17: _t->XSbb_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 18: _t->XSyw_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 19: _t->XShs_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 20: _t->XSll_m((*reinterpret_cast< QString(*)>(_a[1]))); break; case 21: _t->on_Start_clicked(); break; case 22: _t->on_Stop_clicked(); break; case 23: _t->on_pushButton_clicked(); break; case 24: _t->WriteLog((*reinterpret_cast< QString(*)>(_a[1]))); break; case 25: _t->clearD(); break; case 26: _t->showB1(); break; case 27: _t->showB2(); break; case 28: _t->showB3(); break; case 29: _t->showA11(); break; case 30: _t->showA12(); break; case 31: _t->showA21((*reinterpret_cast< QImage(*)>(_a[1]))); break; case 32: _t->showA22((*reinterpret_cast< QImage(*)>(_a[1]))); break; case 33: _t->showA31((*reinterpret_cast< QImage(*)>(_a[1]))); break; case 34: _t->showA32((*reinterpret_cast< QImage(*)>(_a[1]))); break; case 35: _t->YANSHI(); break; case 36: _t->writelogs((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 37: _t->LoadStationA21Img(); break; case 38: _t->LoadStationA22Img((*reinterpret_cast< std::string(*)>(_a[1]))); break; case 39: _t->LoadStationA31Img((*reinterpret_cast< std::string(*)>(_a[1]))); break; case 40: _t->LoadStationA32Img((*reinterpret_cast< std::string(*)>(_a[1]))); break; case 41: _t->resizeWindow(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::openCam)) { *result = 0; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::destroyCam)) { *result = 1; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::startCam)) { *result = 2; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::startcam)) { *result = 3; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::softCam)) { *result = 4; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::SendLog2)) { *result = 5; return; } } { using _t = void (FloorDet::*)(cv::Mat , cv::Mat ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::sendtoolsA)) { *result = 6; return; } } { using _t = void (FloorDet::*)(cv::Mat , cv::Mat ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::sendtoolsB)) { *result = 7; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::chufa)) { *result = 8; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::cfclearD)) { *result = 9; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::pictureA11)) { *result = 10; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::pictureA12)) { *result = 11; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::pictureB1)) { *result = 12; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::pictureB2)) { *result = 13; return; } } { using _t = void (FloorDet::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::pictureB3)) { *result = 14; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XSzs_m)) { *result = 15; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XSng_m)) { *result = 16; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XSbb_m)) { *result = 17; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XSyw_m)) { *result = 18; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XShs_m)) { *result = 19; return; } } { using _t = void (FloorDet::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FloorDet::XSll_m)) { *result = 20; return; } } } }解释一下这段代码
07-30
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangzhangkeji

谢谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值