QT frontend for a C program

Discussion in 'C' started by ljkenny, Feb 12, 2007.

  1. ljkenny

    ljkenny New Member

    Joined:
    Feb 12, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Dear all,

    I am writing a program in C (Not C++) and I need to put a frontend on it.
    I have chosen to use the QT libraries, although, I am open for sensible alternatives.
    I do not, however, know anything about using C and C++ (QT) in the same program.

    Could anybody shed some light, or point me towards a good tutorial please?

    Thanking you in advance!
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    You can call C functions from C++, and vice versa. However, I would think twice about using a C++ class library in a C project.
     
  3. ljkenny

    ljkenny New Member

    Joined:
    Feb 12, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Really? Why so?

    I need a GUI front-end for a C program I am writing.
    What would be the best way to do that then?

    I'll give you a quick run-down on what I am doing.

    I am implementing the HTCPCP (RFC 2324). A copy of which can be found here http://www.faqs.org/rfcs/rfc2324.html
    I'm going to develop a server, written in C which I will have running to act as the coffee pot server. I intend to interface with it wirelessly from a PDA client. Perhaps, like a waiter could do at a cafe. This client has to be written in C too. Now, the server is no problem, however, I wish the PDA to have a GUI on it to make it idiot proof so anyone could use it. For this I need a GUI library. I had intended on using QT.

    Is this going to be a problem? If not, how would I go about doing so?
    If it is going to be a problem, what are my alternatives?

    Thank you for your time once more.
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Because C does not support the use of C++ classes. You could inspect each class and map it to a structure, but you would only gain the use of the data members, not the methods. You could write functions to inspect and manipulate the class members directly, presuming you knew the offsets into the class object. This is not a given, but compiler (and compiler option) dependent. You would also have to write functions to replace any operator overloading that was present.

    In short, you would have to do almost as much work as if you wrote the GUI yourself. The only difference would be in having source code available to tell you what the original authors were doing with the class. That, of course, also presumes open source.

    I'll go so far as to opine that since you don't realize the problems, you will shoot yourself in the foot trying to get around them.

    One alternative is to use C++. Another is to use a GUI library with an API that doesn't require C++. To that end, you might want to check if Qt has an interface that supports C. One used to be able to do that with GTK; I don't know if it's still the case.
     
  5. ljkenny

    ljkenny New Member

    Joined:
    Feb 12, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Ok, I'll look in to that.
    Someone also mentioned something about Kdevelop doing some GUI bits too.

    Thanks for you help so far it is appreciated.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice