[Qt] Using QT GUI Library in Lazarus

Deon Viljoen d.w.viljoen at gmail.com
Thu Sep 24 09:51:46 CEST 2009


Hi All,

I have an existing QT App that I want to integrate into Lazarus. To test
this I have created an dll in QT that creates a QCheckbox.  I am able to
load the checkbox onto a widget in a QT application. However, with Lazarus I
get "Must construct a QApplication before a QPaintDevice".

I am using Lazarus QT 0.9.26.2 and I have QT 4.5 installed. My LCL widgetset
is set to QT in the compiler options and I am able to run all the examples
for the V1.68 FPC binding.

There are two exports in my DLL (TestDLL.dll):
   extern "C" __declspec(dllexport) int GetNum();

   extern "C" __declspec(dllexport) int QCheckBoxDDL_create(int parent);


In Lazarus I have the following import functions:

    function GetNum():longint cdecl; external TestDLL name 'GetNum';
    function QCheckBoxDDL_create(WidgetH: QWidgetH):QWidgetH cdecl; external
TestDLL name 'QCheckBoxDDL_create';


The functions are called by:

   ShowMessage(inttostr(GetNum()));


   MyHandle:=TQtWidget(panel1.Handle).Widget;
   DLLWidget:= QCheckBoxDDL_create(MyHandle);


I can call GetNum() without a problem. However when I call
QCheckBoxDDL_create I get "Must construct a QApplication before a
QPaintDevice"

>From my understanding I gather that the Lazarus app would create a
QApplication when the LCL is set to QT.
Why does the DLL not see it and how do I 'help' the DLL to see it ?
Is it a good idea to create another QApplication object within the DLL?

Thanks in Advance,
Deon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/qt/attachments/20090924/d5b6362a/attachment-0002.html>


More information about the Qt mailing list