Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, April 2007
Usage library with QWidgets in non Qt application


Message 1 in thread

Hello, Colleagues !

I develop Qt library with QObjects QWidgets for Windows and Linux.  Can I
use this library in non-qt application and which way I have to do it ? When
I create some objects which are inherits from QObject in test application I
receive run-time error "QWidget must construct a QApplication before
QPaintDevice". Where is error ?

-- 
 [ signature omitted ] 

Message 2 in thread

On 23.04.07 11:47:50, Yuriy Rusinov wrote:
> I develop Qt library with QObjects QWidgets for Windows and Linux.  Can I
> use this library in non-qt application and which way I have to do it ? When
> I create some objects which are inherits from QObject in test application I
> receive run-time error "QWidget must construct a QApplication before
> QPaintDevice". Where is error ?

The error is right there: You need to create a QApplication and call its
exec(); method before you can create any QWidget instance. I'm not 100%
sure, but I don't think its possible to use Qt widgets in a non-qt
application, you'll always need the Qt event loop.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

> The error is right there: You need to create a QApplication and call its
> exec(); method before you can create any QWidget instance. I'm not 100%
The QApplication is needed for widgets. You do not have to call exec,
however. At least not before creating the widgets. You have to call exec()
on the QApplication afterwards to be able to acutally see and work with the
widgets. (Alternatively, for modal dialogs you can call the dialog's exec()
method.)

If you use simple non graphic stuff (i.e. no widgets) you might be able to
get away with QCoreApplication. If you need only QString, QFile etc. *then*
you might be able to get away w/o a Q(Core)Application object.

But, most importantly:
If you want to show any Qt widgets, you need a Qt event loop.

HTH
Christoph

--
 [ signature omitted ] 

Message 4 in thread

>
>
> If you use simple non graphic stuff (i.e. no widgets) you might be able to
> get away with QCoreApplication. If you need only QString, QFile etc.
> *then*
> you might be able to get away w/o a Q(Core)Application object.
>
> But, most importantly:
> If you want to show any Qt widgets, you need a Qt event loop.


OK, thus I add PostEvent function using conditional compiling into library
object and intercept this message in Visual C++ test application. More over
I add class for QApplication into library.  Thanks a lot.

-- 
 [ signature omitted ]