ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ObjectARX and Qt

22 REPLIES 22
Reply
Message 1 of 23
jamierobertson1
6540 Views, 22 Replies

ObjectARX and Qt

Anyone know if its possible to use Qt classes in an ObjectARX application?
22 REPLIES 22
Message 2 of 23
Anonymous
in reply to: jamierobertson1

I was experiencing with QT for last few days. This question already came into my mind. Following are the notes as per my observaion.

1. Linking the ObjectArx libraries with QT libraries. ( As both of the system are using Visual studio 2005 or similar versions, I feel it would not be a problem)
2. After executing a command suppose we have to display a dialog box, This can be done in following ways
a. Check whether QTApplication has started or not. if it is we can post an event by using QApplication::postEvent() or
QApplication::sendEvent().
3. As we have already used the libraries of both QT and ObjectArx, we can mix ObjectArx Code in QT event handling procedures.

Let me check whether we can link both of the Libraries, I will try to run a test application.

But few questions arise on my mind.

Like, Why you want to use QT libraries in your application as you can integrate C# rich user interface libraries with ObjectArx, Simply you have to write a module to link both C++ and C# applications. I know it is a bit tricky but it can be.

Hope the above observation will help you.

Thnaks & Regards
Anirban Talukdar
talukdar.anirban@gmail.com
Message 3 of 23

Thanks for the reply, I was really just wondering if anyone has tried it before, and if so how painful was the experience and whats possible and not possible?

My plan is to use c# for almost all my UI stuff, the only reason I'd like to use Qt is that I already have alot of Qt code like dialogs with QGraphicsViews and lots of calculations in Qt code etc which Im sure would take me forever to re-write in c# (plus I'm pretty new to c#).

I'm currently thinking the simplest way ahead for me is to use c# as much as possible, keep my Qt stuff seperate and only where really neccesary pop up the occasional Qt widget using COM, I shouldnt really have to pass much data between them so it should be relatively easy.

I'm keen to hear how your test goes,

Regards,

Jamie Robertson
Message 4 of 23
Anonymous
in reply to: jamierobertson1

I will try to run. By the way if you have any overload of works, I can help you in this regard. I am looking for some works.

Thanks & Regards
Anirban Talukdar
Message 5 of 23
Anonymous
in reply to: jamierobertson1

Hi Robetson

I found a good article on this.

http://qtnode.net/wiki/Qt4_with_Visual_Studio

Hope it will help you, I will also try to follow it on weekends.

Thanks & Regards
Anirban Talukdar
Message 6 of 23

Alternatively if your using VS 2008, you can just download the latest version of Qt for VS:



[http://get.qt.nokia.com/qt/source/qt-win-opensource-4.6.0-vs2008.exe] Edited by: jamierobertson1 on Dec 4, 2009 8:50 AM
Message 7 of 23
maisoui
in reply to: jamierobertson1

Hi,

I work on project (AutoCAD integration) implementing Qt in ARX and it works very well.

Have a look on this article http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Windows/qtwinmigrate. It talks about interactions between MFC <-> Qt.

regards
--
Jonathan
Message 8 of 23

Thanks, for that I'll take a look.
Message 9 of 23
Anonymous
in reply to: maisoui

Hello,
i'm trying to integrate Qt in ARX. I have followed the article about migration from mfc to qt. Showing a QMessageBox::about using a QWinWidget succeeds but I do not succeed to show a simple QWidget (analogclock found in qt examples). Could you please give a minimal example of a QWidget shown in a command ?
Regards
Message 10 of 23
maisoui
in reply to: Anonymous

I don't understand why you succeed to display a QMessageBox but not a QDialog. Here's a simple example:

QWinWidget ww(adsw_acadMainWnd());
MyDialog dlg(&ww);
ww.showCentered();
dlg.exec();

Over time, I noticed that problems could appear at the objects deletion (due to QObject architecture, i.e. parent-child), so I recommand to use pointer and call delete in the right place and time.

 

Note: If you want to put Qt in palettes, use a QWinWidget too.

 

Regards,

--
Jonathan
Message 11 of 23
maisoui
in reply to: maisoui

One more thing, assured yourself that you have a valid running QApplication (qApp).

--
Jonathan
Message 12 of 23
Anonymous
in reply to: maisoui

Thank you very much, I think my problem came from the line dlg.exec(); I didn't know on which instance to call exec(). 

Where do you instantiate the QApplication? in the DllMain ? Do you call exec() on it or only on the QDialog ?

Regards

Message 13 of 23
maisoui
in reply to: Anonymous

I chose to initialize QApplication in On_kInitAppMsg and to destroy it (quit) in On_kUnloadAppMsg.

I use Qt for years, and it seems this is a good solution.

Regards,

--
Jonathan
Message 14 of 23
archinfo
in reply to: maisoui

Hi maisoui,

 

I followed your guides, qtwinmigrate and applied to ObjectARX 2015.

 

Succeeded to build ObjectARX MFC sample, "dynamic_dg", today.

But as you said, I encountered Runtime Error message, "...QWidget Must construct a QApplication before a QWidget".

 

Can you help me snippet code about QApplication?

Is it right place below initApp() or where?

Thanks in advance.

 

---------------

extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt)
{
    switch( msg )
    {
    case AcRx::kInitAppMsg:
        acrxUnlockApplication(pkt);
        acrxRegisterAppMDIAware(pkt);
        initApp();

        break;
    case AcRx::kUnloadAppMsg:
        unloadApp();
        break;
    default:
        break;
    }
    return AcRx::kRetOK;
}

 

Message 15 of 23
maisoui
in reply to: archinfo

Hi,

 

Yes, in your initApp you need to allocate a QApplication. You can use QtWinMigrate to create a QMfcApplication or do by yourself :

int argc = 0;
(void)new QApplication(argc, NULL);

 

From my my experience, I can say:

  • You don't need to configure a Windows Hook (using SetWindowsHookEx)
  • Maybe you need to call qApp->processEvents(); just after allocating the QApplication to correctly "initialize" in the events loop

Don't forget to delete your QApplication in your "unload app".

 

Regards,

--
Jonathan
Message 16 of 23
archinfo
in reply to: maisoui

Thank you, Jonathan.

 

Another question I have.

After QApplication added to initApp(), I could not solve error, Qt's Windows Platform loading error, like attachements capture.

 

"This application failed to start because it could not find or load the Qt platform plugin "windows".

Available platform plugins are: minimal, offscreen, windows.

Reinstalling the application may fix this problem."

 

I know about the message, so I did copy them all to my arx folder(--; and autocad folder)

(C:\Qt\5.2.1\msvc2012_64\plugins\platforms\*.dll)

 

Jonathan, you could save me. Thanks a lot.

 

Message 17 of 23
archinfo
in reply to: archinfo


I'm progressing some test scenarios. After that, I'll post my result.
Regards,
Kim.
Message 18 of 23
maisoui
in reply to: archinfo

Yes, you're right. For each OS Qt5 needs to load a specific plugin. For Windows, it's qwindow[d].dll. It's like other Qt plugins, subfolders must be in an accessible path. When you debug, you can simply use : PATH="$(QTDIR)\bin;$(PATH)" (if you have Qt VS addin installed).

Regards,

--
Jonathan
Message 19 of 23
archinfo
in reply to: maisoui

Hi, Jonathan ...

 

I tested basic Qt(5.2.1_x64) Loading on AutoCAD 2015 Platform until now, and succeeded following QMessageBox, very infant code.^^

Thanks for your helps. I'll develop this to next step application using QWinWidget as you said.

Regards,

Myeong Hwan, Kim

 

 

dynamic.arx => AutoCAD MFC Sample

icudt51.dll
icuin51.dll
icuuc51.dll

libEGL.dll

libGLESv2.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll
qwindows.dll => plugins/platform for windows

 

_putenv("QT_QPA_PLATFORM_PLUGIN_PATH=C:/temp"); // Environmental variable 1...
_putenv("PATH=C:/temp;%PATH%"); // Environmental variable 2...
int argc = 0;
(void)new QApplication(argc, NULL);
//qApp->processEvents();
//QMessageBox::critical(0, QObject::tr("Test"), QObject::tr("Critical Messages...")); // OK!
//QMessageBox::about(&win, "About QtMfc", "QtMFC Version 1.0\nCopyright (C) 2014"); // window handle?
QMessageBox::about(0, "About QtMfc", "QtMFC Version 1.0\nCopyright (C) 2014"); //OK!

 

Message 20 of 23
archinfo
in reply to: archinfo

Thanks... I could now implement addin code on AutoCAD, more about Revit using Qt's Dialog.
But, struggling on AutoCAD Palette using QWinWidget Class for this weekend.
Can you guide about that? Everything is helpful.
Especially about QWinWidget's constructor code and QApplication Instance.
Thanks a lot.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost