Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   QT frontend for a C program (http://www.go4expert.com/forums/qt-frontend-c-program-t2963/)

ljkenny 12Feb2007 15:26

QT frontend for a C program
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!

DaWei 12Feb2007 19:33

Re: QT frontend for a C program
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.

ljkenny 12Feb2007 19:56

Re: QT frontend for a C program
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.

DaWei 13Feb2007 02:17

Re: QT frontend for a C program
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.

ljkenny 13Feb2007 02:55

Re: QT frontend for a C program
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.

All times are GMT +5.5. The time now is 05:53.