Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2009-09

Using QT GUI Library in Lazarus

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Deon Viljoen

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.freepascal.org/pipermail/qt/attachments/20090924/d5b6362a/attachment.html>

Deon Viljoen
to Deon Viljoen

Hi,

Finally got it working.

My problem was caused by mixing QT versions and having QT compiled by MSVC while FPC binding was compiled with MinGW.

I downloaded the latest MinGW QT version and everything worked fine after that.

Cheers,
Deon