Hi to all,
i must load a xml file inside On_kInitAppMsg(); I use QT, particulary QXmlSchema.
The source code is very simple:
.....
schema = new QXmlSchema;
schema->setMessageHandler(msgHandler);
if (schema->load(QUrl::fromLocalFile(xsdFilename))) {
result = schema->isValid();
}
.....
when the system executes the 'load' method, the arx loading inside autocad seems go
in loop ... the load fun doesn't return ...
I've put my source code under the comment '// TODO: Add your initialization code here'
Why ? If I execute te code out of the On_kInitAppMsg() for example inside an autocad
command, the code works
Best Regards
Leonard
Solved! Go to Solution.
Solved by maisoui. Go to Solution.
Hi,
Maybe you don't have a valid QCoreApplication? When you talks about loop, it means that application stucks on line schema->load...?
I guess app loading is not the better solution to do long process (like getting data from the Internet), you should execute your code in document loading/activating.
Regards,
Hi,
yesterday I've done qt source debug and the QT 'load' fun stucks
in module qacceltreeresourceloader.cpp, method:
networkLoop.exec(QEventLoop::ExcludeUserInputEvents)
precisely at:
if (networkLoop.exec(QEventLoop::ExcludeUserInputEvents))
{
const QString errorMessage(escape(reply->errorString()));
/* Note, we delete reply before we exit this function with error(). */
delete reply;
const QSourceLocation location(uri);
if(context && (errorHandling == FailOnError))
context->error(errorMessage, ReportContext::FODC0002, location);
return 0;
}
....
Many Thanks
Leonard
No,
I don't have a QApplication istance, my code is:
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt)
{
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
PathTreeXmlScanner xmlScan;
gModel = xmlScan.load(xmlPath);
return (retCode) ;
}
where 'PathTreeXmlScanner' is a my custom class that use QT ...
How I can use QApplication ? If I write:
app.execute();
the execution flow stucks ....
Best Regards
Leonard
It's necessary to create a valid QApplicatoin. (no need to call app.execute(), cause acad.exe is the main process). You just need to create a QApplication.
Have a look to : http://doc.qt.digia.com/solutions/4/qtwinmigrate/qmfcapp.html.
Regards,
Hello Jonathan,
😞 doesn't works ... I've modified the code as follow:
QApplication app();
PathTreeXmlScanner xmlScan;
gModel = xmlScan.load(xmlPath);
Regard
Leonard
QApplication needs to exist as long your ARX is loaded. So use pointer:
int argc = 0; (void)new QApplication(argc, 0);
If you use Qt5, I notice, you need to call once qApp->processEvents(). (don't no why, I'm on the way to migrate from Qt 4.8.5 to Qt 5.2)
Regards,
Hi Jonathan,
🙂 works ! Thank you very much ... If possible I've another strange
problem ObjectArx-Qt ... I've posted it some times ago but I don't
received solution 😞
// --------------------------------------------------------------------------------------------------
I want create a thumbnails dialog with QT, to show a dwg file (one or more dwgs); I've
writed the following codes:
HWND acadHandle = adsw_acadMainWnd();
QWinWidget win(acadHandle);
symPreviewDiag diag(&win); // the QT dialog
::EnableWindow (acadHandle, true);
:etFocus (acadHandle);
diag.setWindowModality(Qt::WindowModality::ApplicationModal);
diag.show();
QPlatformNativeInterface* inter = QGuiApplication:latformNativeInterface();
QWindow* w=diag.windowHandle(); // is NOT equal to 0
HWND h = static_cast<HWND>(inter->nativeResourceForWindow(QByteArrayLiteral("handle"), w)); // is NOT equal to 0
bool b = false;
b = acdbDisplayPreviewFromDwg(result->resval.rstring, h, (Adesk::UInt32 *)RGB(255,0,255)); // the b value is 'true'
diag.update();
(void) a.exec();
I see the qt dialog but i don't see the dwg files ... !
Must I use a QWidget child of QTDialog ?
Which type of QWidget ?
/ -------------------------------------------------------------------------------------------------------------------------------------
Regards
Leonard