#include "mainwindow.h" #include #include "qqtobjectmanager.h" #include "qqtprotocol.h" #include "qqtserver2protocolmanager.h" typedef QObject* ( *Constructor ) ( QObject* parent ); template static QObject* constructorHelper ( QObject* parent = 0 ) { pline() << "created "; return new T ( parent ); } template static dst_type pointer_cast ( src_type src ) { return *static_cast ( static_cast ( &src ) ); } int main ( int argc, char* argv[] ) { QQtApplication a ( argc, argv ); QQtObjectFactory::registerObject(); // QObject* o = QQtObjectFactory::createObject ( "QObject" ); // pline() << o; // QQtObjectFactory::registerObject(); // QObject* obj = QQtObjectFactory::createObject ( "QQtProtocol" ); // QQtProtocol* protocol = dynamic_cast ( obj ); // pline() << protocol; // //protocol->translator ( QByteArray() ); // QObject* obj = metaObj->newInstance ( Q_ARG ( QString, QStringLiteral ( "Rex" ) ), Q_ARG ( QObject*, nullptr ) ); // pline() << obj; // QQtProtocol* an = qobject_cast ( obj ); // pline() << an; QMap instance; void* b = pointer_cast ( &constructorHelper ); pline() << b; Constructor* constructor = ( Constructor* ) b; pline() << constructor; instance.insert ( "aaa", constructor ); pline() << "ffff"; Constructor* func = instance.value ( "aaa" ); pline() << func; Constructor* c = pointer_cast ( &func ); QQtServer2Protocol* p = ( QQtServer2Protocol* ) ( *c ) ( 0 ); pline() << p; p->sendCommand(); //p->translator ( QByteArray() ); MainWindow w; w.show(); QObject* o = QQtObjectFactory::createObject ( "QObject" ); pline() << o; return a.exec(); }