Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 785

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/examples/mdi/mdi.doc:4 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>A MDI Application</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>A MDI Application</h1>

 
<p> 
This example program is just like the application example, but designed as
Multiple Document Interface (MDI).
<p> <hr>
<p> Header file:
<p> <pre>/****************************************************************************
** $Id:  qt/application.h   3.0.2   edited Oct 12 12:18 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#ifndef APPLICATION_H
#define APPLICATION_H

#include &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;
#include &lt;<a href="qptrlist-h.html">qptrlist.h</a>&gt;

class QMultiLineEdit;
class QToolBar;
class QPopupMenu;
class QWorkspace;
class QPopupMenu;
class QMovie;

class MDIWindow: public <a href="qmainwindow.html">QMainWindow</a>
{
    <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
public:
    MDIWindow( <a href="qwidget.html">QWidget</a>* parent, const char* name, int wflags );
    ~MDIWindow();

    void load( const <a href="qstring.html">QString</a>&amp; fn );
    void save();
    void saveAs();
    void print( <a href="qprinter.html">QPrinter</a>* );

signals:
    void message(const <a href="qstring.html">QString</a>&amp;, int );

private:
    <a href="qmultilineedit.html">QMultiLineEdit</a>* medit;
    <a href="qmovie.html">QMovie</a> * mmovie;
    <a href="qstring.html">QString</a> filename;
};


class ApplicationWindow: public <a href="qmainwindow.html">QMainWindow</a>
{
    Q_OBJECT
public:
    ApplicationWindow();
    ~ApplicationWindow();

private slots:
    MDIWindow* newDoc();
    void load();
    void save();
    void saveAs();
    void print();
    void closeWindow();

    void about();
    void aboutQt();

    void windowsMenuAboutToShow();
    void windowsMenuActivated( int id );

private:
    <a href="qprinter.html">QPrinter</a> *printer;
    <a href="qworkspace.html">QWorkspace</a>* ws;
    <a href="qtoolbar.html">QToolBar</a> *fileTools;
    <a href="qpopupmenu.html">QPopupMenu</a>* windowsMenu;
};


#endif
</pre>

<p> <hr>
<p> Implementation:
<p> <pre>/****************************************************************************
** $Id:  qt/application.cpp   3.0.2   edited Oct 12 12:18 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include "application.h"
#include &lt;<a href="qworkspace-h.html">qworkspace.h</a>&gt;
#include &lt;<a href="qimage-h.html">qimage.h</a>&gt;
#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;
#include &lt;<a href="qtoolbar-h.html">qtoolbar.h</a>&gt;
#include &lt;<a href="qtoolbutton-h.html">qtoolbutton.h</a>&gt;
#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;
#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;
#include &lt;<a href="qmovie-h.html">qmovie.h</a>&gt;
#include &lt;<a href="qmultilineedit-h.html">qmultilineedit.h</a>&gt;
#include &lt;<a href="qfile-h.html">qfile.h</a>&gt;
#include &lt;<a href="qfiledialog-h.html">qfiledialog.h</a>&gt;
#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
#include &lt;<a href="qstatusbar-h.html">qstatusbar.h</a>&gt;
#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;
#include &lt;<a href="qprinter-h.html">qprinter.h</a>&gt;
#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;
#include &lt;<a href="qaccel-h.html">qaccel.h</a>&gt;
#include &lt;<a href="qtextstream-h.html">qtextstream.h</a>&gt;
#include &lt;<a href="qpainter-h.html">qpainter.h</a>&gt;
#include &lt;<a href="qpaintdevicemetrics-h.html">qpaintdevicemetrics.h</a>&gt;
#include &lt;<a href="qwhatsthis-h.html">qwhatsthis.h</a>&gt;
#include &lt;qobjectlist.h&gt;
#include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;

#include "filesave.xpm"
#include "fileopen.xpm"
#include "fileprint.xpm"


const char * fileOpenText = "Click this button to open a &lt;em&gt;new file&lt;/em&gt;. &lt;br&gt;&lt;br&gt;"
"You can also select the &lt;b&gt;Open command&lt;/b&gt; from the File menu.";
const char * fileSaveText = "Click this button to save the file you are "
"editing.  You will be prompted for a file name.\n\n"
"You can also select the Save command from the File menu.\n\n"
"Note that implementing this function is left as an exercise for the reader.";
const char * filePrintText = "Click this button to print the file you "
"are editing.\n\n"
"You can also select the Print command from the File menu.";

<a name="f354"></a>ApplicationWindow::ApplicationWindow()
    : <a href="qmainwindow.html">QMainWindow</a>( 0, "example application main window", WDestructiveClose )
{
    int id;

    <a href="qpixmap.html">QPixmap</a> openIcon, saveIcon;

    fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
    <a href="qmainwindow.html#addToolBar">addToolBar</a>( fileTools, tr( "File Operations" ), DockTop, TRUE );

    openIcon = QPixmap( fileopen );
    QToolButton * fileOpen
        = new <a href="qtoolbutton.html">QToolButton</a>( openIcon, "Open File", <a href="qstring.html#QString-null">QString::null</a>,
                           this, SLOT(load()), fileTools, "open file" );

    saveIcon = QPixmap( filesave );
    QToolButton * fileSave
        = new <a href="qtoolbutton.html">QToolButton</a>( saveIcon, "Save File", QString::null,
                           this, SLOT(save()), fileTools, "save file" );

#ifndef QT_NO_PRINTER
    printer = new <a href="qprinter.html">QPrinter</a>;
    <a href="qpixmap.html">QPixmap</a> printIcon;

    printIcon = QPixmap( fileprint );
    QToolButton * filePrint
        = new <a href="qtoolbutton.html">QToolButton</a>( printIcon, "Print File", QString::null,
                           this, SLOT(print()), fileTools, "print file" );
<a name="x1179"></a>    QWhatsThis::<a href="qwhatsthis.html#add">add</a>( filePrint, filePrintText );
#endif

    (void)QWhatsThis::whatsThisButton( fileTools );

    QWhatsThis::<a href="qwhatsthis.html#add">add</a>( fileOpen, fileOpenText );
    QWhatsThis::<a href="qwhatsthis.html#add">add</a>( fileSave, fileSaveText );

    <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
    <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );

<a name="x1148"></a>    file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;New", this, SLOT(newDoc()), CTRL+Key_N );

    id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( openIcon, "&amp;Open...",
                           this, SLOT(load()), CTRL+Key_O );
<a name="x1153"></a>    file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileOpenText );

    id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( saveIcon, "&amp;Save",
                           this, SLOT(save()), CTRL+Key_S );
    file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
    id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Save &amp;As...", this, SLOT(saveAs()) );
    file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
#ifndef QT_NO_PRINTER
<a name="x1149"></a>    file-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
    id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( printIcon, "&amp;Print...",
                           this, SLOT(print()), CTRL+Key_P );
    file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, filePrintText );
#endif
    file-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
    file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;Close", this, SLOT(closeWindow()), CTRL+Key_W );
<a name="x1140"></a>    file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;Quit", qApp, SLOT( <a href="qapplication.html#closeAllWindows">closeAllWindows</a>() ), CTRL+Key_Q );

    windowsMenu = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
<a name="x1167"></a>    windowsMenu-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
<a name="x1166"></a>    <a href="qobject.html#connect">connect</a>( windowsMenu, SIGNAL( <a href="qpopupmenu.html#aboutToShow">aboutToShow</a>() ),
             this, SLOT( windowsMenuAboutToShow() ) );
    <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Windows", windowsMenu );

    <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertSeparator();
    <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
    <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Help", help );

    help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;About", this, SLOT(about()), Key_F1);
    help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "About &amp;Qt", this, SLOT(aboutQt()));
    help-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
    help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "What's &amp;This", this, SLOT(<a href="qmainwindow.html#whatsThis">whatsThis</a>()), SHIFT+Key_F1);

    <a href="qvbox.html">QVBox</a>* vb = new <a href="qvbox.html">QVBox</a>( this );
    vb-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::StyledPanel | QFrame::Sunken );
    ws = new <a href="qworkspace.html">QWorkspace</a>( vb );
<a name="x1191"></a>    ws-&gt;<a href="qworkspace.html#setScrollBarsEnabled">setScrollBarsEnabled</a>( TRUE );
    <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( vb );

    <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Ready", 2000 );
}


ApplicationWindow::~ApplicationWindow()
{
#ifndef QT_NO_PRINTER
    delete printer;
#endif
}



MDIWindow* <a name="f355"></a>ApplicationWindow::newDoc()
{
    MDIWindow* w = new MDIWindow( ws, 0, WDestructiveClose );
    <a href="qobject.html#connect">connect</a>( w, SIGNAL( message(const <a href="qstring.html">QString</a>&amp;, int) ), statusBar(), SLOT( message(const <a href="qstring.html">QString</a>&amp;, int )) );
    w-&gt;<a href="qwidget.html#setCaption">setCaption</a>("unnamed document");
<a name="x1185"></a>    w-&gt;<a href="qwidget.html#setIcon">setIcon</a>( QPixmap("document.xpm") );
    // show the very first window in maximized mode
<a name="x1193"></a>    if ( ws-&gt;<a href="qworkspace.html#windowList">windowList</a>().isEmpty() )
<a name="x1187"></a>        w-&gt;<a href="qwidget.html#showMaximized">showMaximized</a>();
    else
        w-&gt;<a href="qwidget.html#show">show</a>();
    return w;
}

void <a name="f356"></a>ApplicationWindow::load()
{
<a name="x1143"></a>    <a href="qstring.html">QString</a> fn = QFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( QString::null, QString::null, this );
    if ( !fn.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
        MDIWindow* w = newDoc();
        w-&gt;load( fn );
    }  else {
        <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Loading aborted", 2000 );
    }
}

void <a name="f357"></a>ApplicationWindow::save()
{
<a name="x1189"></a>    MDIWindow* m = (MDIWindow*)ws-&gt;<a href="qworkspace.html#activeWindow">activeWindow</a>();
    if ( m )
        m-&gt;save();
}


void <a name="f358"></a>ApplicationWindow::saveAs()
{
    MDIWindow* m = (MDIWindow*)ws-&gt;<a href="qworkspace.html#activeWindow">activeWindow</a>();
    if ( m )
        m-&gt;saveAs();
}


void <a name="f359"></a>ApplicationWindow::print()
{
#ifndef QT_NO_PRINTER
    MDIWindow* m = (MDIWindow*)ws-&gt;<a href="qworkspace.html#activeWindow">activeWindow</a>();
    if ( m )
        m-&gt;print( printer );
#endif
}


void <a name="f360"></a>ApplicationWindow::closeWindow()
{
    MDIWindow* m = (MDIWindow*)ws-&gt;<a href="qworkspace.html#activeWindow">activeWindow</a>();
    if ( m )
<a name="x1180"></a>        m-&gt;<a href="qwidget.html#close">close</a>();
}

void <a name="f361"></a>ApplicationWindow::about()
{
<a name="x1154"></a>    QMessageBox::<a href="qmessagebox.html#about">about</a>( this, "Qt Application Example",
                        "This example demonstrates simple use of\n "
                        "Qt's Multiple Document Interface (MDI).");
}


void <a name="f362"></a>ApplicationWindow::aboutQt()
{
<a name="x1155"></a>    QMessageBox::<a href="qmessagebox.html#aboutQt">aboutQt</a>( this, "Qt Application Example" );
}


void <a name="f363"></a>ApplicationWindow::windowsMenuAboutToShow()
{
<a name="x1147"></a>    windowsMenu-&gt;<a href="qmenudata.html#clear">clear</a>();
<a name="x1190"></a>    int cascadeId = windowsMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>("&amp;Cascade", ws, SLOT(<a href="qworkspace.html#cascade">cascade</a>() ) );
<a name="x1192"></a>    int tileId = windowsMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>("&amp;Tile", ws, SLOT(<a href="qworkspace.html#tile">tile</a>() ) );
    if ( ws-&gt;<a href="qworkspace.html#windowList">windowList</a>().isEmpty() ) {
<a name="x1151"></a>        windowsMenu-&gt;<a href="qmenudata.html#setItemEnabled">setItemEnabled</a>( cascadeId, FALSE );
        windowsMenu-&gt;<a href="qmenudata.html#setItemEnabled">setItemEnabled</a>( tileId, FALSE );
    }
    windowsMenu-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
    QWidgetList windows = ws-&gt;<a href="qworkspace.html#windowList">windowList</a>();
<a name="x1171"></a>    for ( int i = 0; i &lt; int(windows.count()); ++i ) {
<a name="x1170"></a>        int id = windowsMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>(windows.at(i)-&gt;caption(),
                                         this, SLOT( windowsMenuActivated( int ) ) );
<a name="x1152"></a>        windowsMenu-&gt;<a href="qmenudata.html#setItemParameter">setItemParameter</a>( id, i );
<a name="x1150"></a>        windowsMenu-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( id, ws-&gt;<a href="qworkspace.html#activeWindow">activeWindow</a>() == windows.at(i) );
    }
}

void <a name="f364"></a>ApplicationWindow::windowsMenuActivated( int id )
{
    <a href="qwidget.html">QWidget</a>* w = ws-&gt;<a href="qworkspace.html#windowList">windowList</a>().at( id );
    if ( w )
<a name="x1188"></a>        w-&gt;<a href="qwidget.html#showNormal">showNormal</a>();
    w-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
}

<a name="f365"></a>MDIWindow::MDIWindow( <a href="qwidget.html">QWidget</a>* parent, const char* name, int wflags )
    : <a href="qmainwindow.html">QMainWindow</a>( parent, name, wflags )
{
    mmovie = 0;
    medit = new <a href="qmultilineedit.html">QMultiLineEdit</a>( this );
    <a href="qwidget.html#setFocusProxy">setFocusProxy</a>( medit );
    <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( medit );
}

MDIWindow::~MDIWindow()
{
    delete mmovie;
}


void <a name="f366"></a>MDIWindow::load( const <a href="qstring.html">QString</a>&amp; fn )
{
    filename  = fn;
    <a href="qfile.html">QFile</a> f( filename );
<a name="x1142"></a>    if ( !f.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) )
        return;

<a name="x1172"></a>    if(fn.<a href="qstring.html#contains">contains</a>(".gif")) {
        <a href="qwidget.html">QWidget</a> * tmp=new <a href="qwidget.html">QWidget</a>(this);
        <a href="qwidget.html#setFocusProxy">setFocusProxy</a>(tmp);
        <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>(tmp);
<a name="x1181"></a>        medit-&gt;<a href="qwidget.html#hide">hide</a>();
        delete medit;
        <a href="qmovie.html">QMovie</a> * qm=new <a href="qmovie.html">QMovie</a>(fn);
#ifdef Q_WS_QWS // temporary speed-test hack
<a name="x1156"></a>        qm-&gt;setDisplayWidget(tmp);
#endif
<a name="x1182"></a>        tmp-&gt;<a href="qwidget.html#setBackgroundMode">setBackgroundMode</a>(QWidget::NoBackground);
        tmp-&gt;<a href="qwidget.html#show">show</a>();
        mmovie=qm;
    } else {
        mmovie = 0;

        <a href="qtextstream.html">QTextStream</a> t(&amp;f);
<a name="x1178"></a>        <a href="qstring.html">QString</a> s = t.<a href="qtextstream.html#read">read</a>();
        medit-&gt;<a href="qtextedit.html#setText">setText</a>( s );
<a name="x1141"></a>        f.<a href="qfile.html#close">close</a>();


    }
    <a href="qwidget.html#setCaption">setCaption</a>( filename );
    emit message( QString("Loaded document %1").arg(filename), 2000 );
}

void <a name="f367"></a>MDIWindow::save()
{
    if ( filename.isEmpty() ) {
        saveAs();
        return;
    }

<a name="x1177"></a>    <a href="qstring.html">QString</a> text = medit-&gt;<a href="qtextedit.html#text">text</a>();
    <a href="qfile.html">QFile</a> f( filename );
    if ( !f.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> ) ) {
        emit message( QString("Could not write to %1").arg(filename),
                      2000 );
        return;
    }

    <a href="qtextstream.html">QTextStream</a> t( &amp;f );
    t &lt;&lt; text;
    f.<a href="qfile.html#close">close</a>();

    <a href="qwidget.html#setCaption">setCaption</a>( filename );

    emit message( QString( "File %1 saved" ).arg( filename ), 2000 );
}

void <a name="f368"></a>MDIWindow::saveAs()
{
<a name="x1144"></a>    <a href="qstring.html">QString</a> fn = QFileDialog::<a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>( filename, QString::null, this );
    if ( !fn.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
        filename = fn;
        save();
    } else {
        emit message( "Saving aborted", 2000 );
    }
}

void <a name="f369"></a>MDIWindow::print( <a href="qprinter.html">QPrinter</a>* printer)
{
#ifndef QT_NO_PRINTER
    const int Margin = 10;
    int pageNo = 1;

<a name="x1169"></a>    if ( printer-&gt;<a href="qprinter.html#setup">setup</a>(this) ) {               // printer dialog
        emit message( "Printing...", 0 );
        <a href="qpainter.html">QPainter</a> p;
        if ( !p.<a href="qpainter.html#begin">begin</a>( printer ) )
            return;                             // paint on printer
<a name="x1175"></a>        p.<a href="qpainter.html#setFont">setFont</a>( medit-&gt;<a href="qtextedit.html#font">font</a>() );
        int yPos        = 0;                    // y position for each line
<a name="x1164"></a>        <a href="qfontmetrics.html">QFontMetrics</a> fm = p.<a href="qpainter.html#fontMetrics">fontMetrics</a>();
        <a href="qpaintdevicemetrics.html">QPaintDeviceMetrics</a> metrics( printer ); // need width/height
        // of printer surface
<a name="x1157"></a>        for( int i = 0 ; i &lt; medit-&gt;<a href="qmultilineedit.html#numLines">numLines</a>() ; i++ ) {
<a name="x1159"></a>            if ( Margin + yPos &gt; metrics.<a href="qpaintdevicemetrics.html#height">height</a>() - Margin ) {
                <a href="qstring.html">QString</a> msg( "Printing (page " );
<a name="x1174"></a>                msg += QString::<a href="qstring.html#number">number</a>( ++pageNo );
                msg += ")...";
                emit message( msg, 0 );
<a name="x1168"></a>                printer-&gt;<a href="qprinter.html#newPage">newPage</a>();             // no more room on this page
                yPos = 0;                       // back to top of page
            }
            p.<a href="qpainter.html#drawText">drawText</a>( Margin, Margin + yPos,
<a name="x1160"></a><a name="x1145"></a>                        metrics.<a href="qpaintdevicemetrics.html#width">width</a>(), fm.<a href="qfontmetrics.html#lineSpacing">lineSpacing</a>(),
                        ExpandTabs | DontClip,
<a name="x1158"></a>                        medit-&gt;<a href="qmultilineedit.html#textLine">textLine</a>( i ) );
            yPos = yPos + fm.<a href="qfontmetrics.html#lineSpacing">lineSpacing</a>();
        }
        p.<a href="qpainter.html#end">end</a>();                                // send job to printer
        emit message( "Printing completed", 2000 );
    } else {
        emit message( "Printing aborted", 2000 );
    }
#endif
}


</pre>

<p> <hr>
<p> Main:
<p> <pre>/****************************************************************************
** $Id:  qt/main.cpp   3.0.2   edited Oct 12 12:18 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include "application.h"

int main( int argc, char ** argv ) {
    <a href="qapplication.html">QApplication</a> a( argc, argv );
    ApplicationWindow * mw = new ApplicationWindow();
    mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Multiple Documents Interface (MDI)" );
    mw-&gt;<a href="qwidget.html#show">show</a>();
<a name="x1197"></a><a name="x1195"></a>    a.<a href="qobject.html#connect">connect</a>( &amp;a, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), &amp;a, SLOT(<a href="qapplication.html#quit">quit</a>()) );
    int res = a.<a href="qapplication.html#exec">exec</a>();
    return res;
}
</pre>

<p>See also <a href="examples.html">Examples</a>.

<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>