From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- doc/html/motif-walkthrough-6.html | 129 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 doc/html/motif-walkthrough-6.html (limited to 'doc/html/motif-walkthrough-6.html') diff --git a/doc/html/motif-walkthrough-6.html b/doc/html/motif-walkthrough-6.html new file mode 100644 index 000000000..802f205d5 --- /dev/null +++ b/doc/html/motif-walkthrough-6.html @@ -0,0 +1,129 @@ + + + + + +Using TQt Main Window Classes + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

Using TQt Main Window Classes

+ + + +[ Previous: Using Existing Dialogs with TQMotifDialog ] +[ Home ] +[ Next: Refactoring Existing Code ] +

After we have replaced all the dialogs, we are ready to begin replacing +the Main Window. As mentioned +above, we will replace the existing XmMainWindow and +popup-menu heirarchy with TQt Main Window +Classes. +

We will use TQt Designer to design +our new main window. +

Implementing the Main Window +

+

The description for the Main Window is saved as mainwindow.ui. +We add this file to the project file and regenerate the Makefile. +The uic utility generates the code for our Main Window, which +is then compiled and linked into our application. +

TQt Designer also created the mainwindow.ui.h file. We need to +add the implementation for our Main Window to this skeleton +implementation. +

We begin by adding the necessary includes for TQApplication +and TQMotifWidget. +

+ +


+

We need includes for the Motif callback structs and the XmdPrint +widget. +


+

We are now ready to add implementations for the slots in our Main Window. We have one slot per menu item. Each slot will call the +existing callback functions found in todo.cpp and actions.cpp. +

+
File menu +
New MainWindow::fileNew() calls the New() callback +
Open MainWindow::fileOpen() calls the Open() callback +
Save MainWindow::fileSave() calls the SaveIt() callback +
Save As MainWindow::fileSaveAs() calls the Save() callback +
Print MainWindow::filePrint() calls the ShowPrintDialog() callback +
Exit MainWindow::fileExit() calls TQApplication::tquit() +
Selected menu +
Properties MainWindow::selProperties() calls the EditPage() callback +
New MainWindow::selNewPage() calls the NewPage() callback +
Delete to Trash MainWindow::selDeletePage() calls the DeletePage() callback +
+

We need to add forward declarations for these callbacks before we can +use them. +


+

Each of the existing callback functions takes three arguments. We pass +NULL to all of the arguments in this example (with a few exceptions, +see below). The existing code does not rely on any of the arguments. +Each slot implementation is a single line calling the related callback +function. The code is not very interesting and would just take up +space, so we've omitted it. +

There are four exceptions to the above. The Open(), Save(), EditPage() and DeletePage() callbacks accept a pointer to the +toplevel TQWidget as argument 2 (the client_data argument). For +these four functions, we pass this as the second argument, which is +a toplevel MainWindow derived from TQMainWindow. +

Replacing the Main Window +

+

The next step is to use the new Main Window in our application. +The changes needed in todo.cpp are large due to the large amount of +code being removed. +

First, we add the include for our new Main Window. +

+ +


+

We can cleanup the Motif includes, since many of them are no longer +needed. +


+

The QuitAppl() and manageCB() callbacks are not needed any more, +so we remove them. We do not need the global shell variable +either. We remove it and all references to it in the New(), Save() and Open() callbacks. +

In main(), we make the large changes. First, we use our new MainWindow instead of TQMotifWidget with XmMainWindow. +

+ +


+

We will now use TQMotifWidget to create the XmNotebook widget. +


+

We remove all of the code used to create the Motif menus. The +remaining code in main() is self-explanatory. +


+

Our application is now using TQMainWindow instead of XmMainWindow. +After we build the project, the application runs and operates as +expected. +

[ Previous: Using Existing Dialogs with TQMotifDialog ] +[ Home ] +[ Next: Refactoring Existing Code ] +

+ +


+ +
Copyright © 2007 +TrolltechTrademarks +
TQt 3.3.8
+
+ -- cgit v1.2.1