if (!qApp) { int argc = 0; new QApplication(argc, 0);}
QCoreApplication::processEvents
QTimer::singleShot
void TThread::run(){ pApp->exec();}void TThread::stop(){ pApp->quit();}TTestCommand::TTestCommand() :TTest(){ int argc=1; char *argv[1]; argv[0]="templatedll.dll"; pApp = new QApplication(argc, argv); thread = new TThread(); thread->start(); // for c/p : templatedll.dll wnd = new CommandWindow(); wnd->show(); //wnd->setVisible(false);}TTestCommand::~TTestCommand(){ thread->stop(); thread->wait(); delete pApp;}void* TTestCommand::GetHWND(){ return wnd->winId();}TTest* __declspec(dllexport) CreateObject(){ return new TTestCommand();}
typedef TTest* (*TCreateObject)();HINSTANCE hUiiDrv_ID;TCreateObject CreateObject; try{ hUiiDrv_ID = LoadLibrary( Edit1->Text.c_str() ); } catch(...) { return; } if( (CreateObject = (TCreateObject) GetProcAddress(hUiiDrv_ID, "CreateObject"))==NULL ) return; TTest* tst = CreateObject(); hwnd = tst->GetHWND(); ::SetParent(hwnd, (HWND)(Panel1->Handle));
#include <QWinWidget>class SignalsWindow : public QWinWidget{ Q_OBJECTpublic: explicit SignalsWindow(HWND parent = 0); ~SignalsWindow();private: Ui::SignalsWindow *ui;};
bool Init(HINSTANCE hInstance){ // Под Windows устанавливаем кодировку cp1251#ifdef Q_WS_WIN QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251")); // Под остальными ОС - utf8#else QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));#endif ownApplication = QMfcApp::pluginInstance( hInstance ); return TRUE;}//---------------------------------------------------------bool Close(){ if(ownApplication) delete qApp; delete TestSignals; return TRUE;}//---------------------------------------------------------HWND __declspec(dllexport) CreateObject(HWND hParent){ TestWnd = new SignalsWindow(hParent) TestWnd->setWindowState(Qt::WindowMaximized); TestWnd->show(); return TestWnd->winId();}