[Qt-interest] Using a Qt class in a non-Qt app?
Francisco Ares
frares at gmail.com
Wed Sep 30 22:45:35 CEST 2009
Here is the basic "main.cpp" file, created for a new project:
#include "myapp.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MyApp w();
w.show();
return a.exec();
}
There really is a main loop for events, and classes that are supposed to
support events should have a Q_OBJECT macro declared this way:
...
class MyApp: public QMainWindow, private Ui::MyAppClass {
Q_OBJECT
public:
MyApp(QWidget *parent = 0);
...
not exactly this way, of course.
Hope this helps
Francisco
On Wed, Sep 30, 2009 at 4:57 PM, Constantin Makshin <
dinosaur-rus at users.sourceforge.net> wrote:
> For GUI-less applications use QCoreApplication class instead of
> QApplication.
>
> On Wed, 30 Sep 2009 23:40:37 +0400, Brant Sears <brant at mac.com> wrote:
> > Hi. I have a Cocoa/Carbon application that I want to modify into a Qt
> > application. The current application has a user interface written in
> > Carbon & Cocoa. The Qt application will not have a UI - it will send
> > xml based messages to another application which will display the user
> > interface. Therefore, I would like to be able to add some of the Qt
> > networking classes to my Carbon/Cocoa app first and work on sending
> > the data across so that I can see that the UI between the original app
> > and the new app is the same. Then as a last step, I would remove the
> > Carbon/Cocoa User Interface.
> >
> > The problem I am having is that my slots are not getting called which
> > I think is because I do not have a QApplication. Therefore, there
> > isn't an application run loop dispatching these events.
> >
> > I could add such a thing, but then I would short circuit the
> > NSApplication object that Cocoa uses.
> >
> > Any idea as to what I should do here?
> >
> > If not, my best idea is to try to port over the mac app into Qt a
> > little bit at a time which will result in having a non-working app for
> > a period of time (less desirable). So, before I go there, I wanted to
> > ask if there is a way to use a QLocalSocket and have the slots be
> > correctly called from a non-Qt app.
> >
> > Thanks for any advice.
>
> --
> Constantin Makshin
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
"If you have an apple and I have an apple and we exchange apples then you
and I will still each have one apple. But if you have an idea and I have one
idea and we exchange these ideas, then each of us will have two ideas." -
George Bernard Shaw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090930/a9ad7558/attachment.html
More information about the Qt-interest-old
mailing list