From bd0f3345a938b35ce6a12f6150373b0955b8dd12 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:24:15 -0500 Subject: Add Qt3 development HEAD version --- doc/html/motif-walkthrough-1.html | 98 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 doc/html/motif-walkthrough-1.html (limited to 'doc/html/motif-walkthrough-1.html') diff --git a/doc/html/motif-walkthrough-1.html b/doc/html/motif-walkthrough-1.html new file mode 100644 index 0000000..f320757 --- /dev/null +++ b/doc/html/motif-walkthrough-1.html @@ -0,0 +1,98 @@ + + + + + +Getting Started + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

Getting Started

+ + + +[ Home ] +[ Next: Preparing to Migrate the User Interface ] +

Starting with QMotif and QApplication +

+

To be able to use Qt, we need to create a QApplication object. The +QApplication class controls all the event delivery and display +management for all other Qt objects and widgets. We need to use the +QMotif class from the Qt Motif Extension to allow QApplication +and the XtAppContext to coexist. +

The QApplication object must be created in the main() function. +We will need to modify todo.c to compile with a C++ compiler, so we +rename todo.c to todo.cpp. +

Next, we add the appropriate includes for the QMotif and QApplication +classes. +

+ +


+

Next, we create the QMotif and QApplication objects. We create QMotif +with a foreign XtAppContext, and we create QApplication with a +foreign Display. +


+

The next change is not yet necessary, but it is included to show that +the Qt Motif Extension provides a complete integration. +Normally, a Motif based program would use the XtAppMainLoop() +function to run the application's event loop. This is still possible, +but since we are migrating to the Qt toolkit, we prefer to use the +QApplication::exec() function for running the event loop. +


+

Since we renamed todo.c to todo.cpp, we must change the +project file and rerun qmake to regenerate our Makefile. When we +build our project, there are compile and link errors: we will fix +these in the following section. +

Migrating to C++ +

+

We need to convert the code in this file to proper C++ code. +Fortunately, the changes are not too large. Most files included from +existing C projects are not C++ compatible, so we make them compatible +by wrapping them in an extern "C" block. +

+ +


+

Global C functions that are forward declared must also be wrapped into +an extern "C" block. +


+

The manageCB() function needs to be converted to proper C++. +


+

And we need to fix two invalid casts. One is in the Save() function. +


+

The other invalid cast is in the Open() function. +


+

After these changes, the project compiles and links, and the +application runs and operates correctly. +

[ Home ] +[ Next: Preparing to Migrate the User Interface ] +

+ +


+ +
Copyright © 2007 +TrolltechTrademarks +
Qt 3.3.8
+
+ -- cgit v1.2.3