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-9.html | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 doc/html/motif-walkthrough-9.html (limited to 'doc/html/motif-walkthrough-9.html') diff --git a/doc/html/motif-walkthrough-9.html b/doc/html/motif-walkthrough-9.html new file mode 100644 index 000000000..4c0cc9dc6 --- /dev/null +++ b/doc/html/motif-walkthrough-9.html @@ -0,0 +1,104 @@ + + + + + +Replacing the Print Dialog + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

Replacing the Print Dialog

+ + + +[ Previous: Replacing the View Widget ] +[ Home ] +[ Next: Continuing Development ] +

The Print dialog is the last component in our application that +uses Motif. The current Print() function does nothing more than +write the plain text to a temporary file, and then executes 'lpr' to +send the text to the printer. Since we will use TQPrinter, we do not +this function any more, so we remove it. The current MainWindow::filePrint() implementation is removed as well. We will +write a new MainWindow::filePrint() implementation in mainwindow.ui.h. +

Note: The steps involved in using the TQPrinter class are beyond the +scope of this walkthrough and will not be discussed here. The +TQPrinter Class Reference, TQSimpleRichText Class Reference and the +Simple Application Walkthrough +contain information on the use of TQPrinter. +

For completeness, the code to initialize a TQPrinter object is included below. +

+ +


+

Using Rich Text for Printing +

+

TQt provides rich text using a subset of HTML. The TQSimpleRichText +class makes rich-text printing simple. All we need to do is create a +string with the proper format tags inserted at the appropriate +places. For our example, we will keep the printing output similar to +previous versions. +

First, we create the format tags that we will use. +


+

Next we just loop over all pages, appending the page label, contents +and formatting characters to a printtext variable (which is a +TQString). +


+

The rest of the MainWindow::filePrint() function is the actual +printing code. Here we simply create a TQSimpleRichText object using +the string we created above, and draw this string on the TQPrinter +object using TQPainter. +


+

Removing the Dependency on Xt/Motif +

+

Our application no longer uses any Xt or Motif widgets. We can now +finish removing the dependencies on Xt and Motif. +

First, we cleanup the #include statements in mainwindow.ui.h. +

+ +


+

The MainWindow::fileNew() function uses the Boolean and False +keywords from the Xt library. C++ has these built into the language, +so we use bool and false instead. +

The last modification needed to completely remove Xt and Motif from +our application is to stop using the TQMotif class. We remove the +qmotif.h #include statement from todo.cpp, and remove the +instantiation from the main() function. +

After doing this, we can remove the -lXm and -lqmotif from the +LIBS variable in our project file. Our project file also contains +source and headers for the the old custom Motif widgets previously +used in our application. We remove these as well. +

After regenerating the Makefile and building our project, we +confirm that the application works correctly. +

[ Previous: Replacing the View Widget ] +[ Home ] +[ Next: Continuing Development ] +

+ +


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