Results 1 to 7 of 7

Thread: creating Qt libraries

  1. #1
    Join Date
    Sep 2006
    Posts
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default creating Qt libraries

    Hi to all,
    I' like to know your advice on the following topic:
    Would it be possible to compile a Qt based application as a library, and then importing and using it from a C program?

    I've seen that there are several ways for performing the inverse operation (using C code in Qt/C++ programs), but only little documentation on this topic.

    I've seen the QtC RPMs, for using Qt into C programs, but I'm using an embedded
    version of qt, with a lot of custom widget, and I have to solve it VERY shortly.

    Any help will be very wellcome.

    Best regards to everyone!

    Stefano

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: creating Qt libraries

    Qt needs a running event loop. You could try to invoke a library function that creates QApplication instance and starts the event loop, but it won't return until you stop the Qt part of your program.

  3. #3
    Join Date
    Sep 2006
    Posts
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: creating Qt libraries

    Mmmmmh.
    Sounds quite tricky.

    I explain better the situation.
    I have an application, written entirely in C language. It must continuosly visualize on a screen the variation of a parameter. The 'graphical' part of the app must be Qt based. So I need to start the Qt program from the C one and continuosly pass to it values to be displayed.

    If I understand well your answer, it could be possible at least start the Qt part of the program, with its event loop, but then the c program would lay until the Qt runs, isn't it?

    Maybe I could propose the reverse solution, the 'leading' aplication written in C++ and the C code inserted inside with, let's say, the "extern 'C'" keyword....

    Of course I'm always open for simpler (and faster) solutions.....
    However, Thank you very much.....

    Stefano

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: creating Qt libraries

    Maybe it could be easier to incorporate the C application into the Qt-based GUI as a separate thread? Alternatively you can connect to the base app's stdin and stdout and communicate with it from a separate (GUI) process.

  5. #5
    Join Date
    Sep 2006
    Posts
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: creating Qt libraries

    Uhm....
    you mean connecting to the base application by use of an istance of the QProcess class?

    This sound veeery nice.....

    Ok, thanks a lot.
    I will update you with the progresses, if any....

    Bye,

    Stefano

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: creating Qt libraries

    Quote Originally Posted by stefano_p
    Uhm....
    you mean connecting to the base application by use of an istance of the QProcess class?
    Yes.

    This sound veeery nice.....
    Yes, if the base application allows controlling it through stdin/stdout.

  7. #7
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: creating Qt libraries

    Sounds like a job for IPC. If you're using X11, then Qt 4.2 has dbus for a good IPC mechanism. Otherwise you'll need to roll your own, possibly using QProcess.

  8. The following user says thank you to Brandybuck for this useful post:

    sunil.thaha (12th September 2006)

Similar Threads

  1. Standardization on libraries
    By brcain in forum General Discussion
    Replies: 13
    Last Post: 16th August 2006, 22:56
  2. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:05
  3. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13
  4. Replies: 4
    Last Post: 7th March 2006, 08:52
  5. Creating a "windowless" software
    By Yorma in forum Qt Programming
    Replies: 7
    Last Post: 9th January 2006, 15:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.