Sophie

Sophie

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

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/tabdialog/tabdialog.doc:4 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Tabdialog</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>Tabdialog</h1>

   
<p> 
This example shows how to use a dialog with multiple tabs
(pages). To start the program you have to specify a filename
as the first argument. The dialog shows information about the
file separated onto different tabs.
<p> <hr>
<p> Header file:
<p> <pre>/****************************************************************************
** $Id:  qt/tabdialog.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 TABDIALOG_H
#define TABDIALOG_H

#include &lt;<a href="qtabdialog-h.html">qtabdialog.h</a>&gt;
#include &lt;<a href="qstring-h.html">qstring.h</a>&gt;
#include &lt;<a href="qfileinfo-h.html">qfileinfo.h</a>&gt;

class TabDialog : public <a href="qtabdialog.html">QTabDialog</a>
{
    <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>

public:
    TabDialog( <a href="qwidget.html">QWidget</a> *parent, const char *name, const <a href="qstring.html">QString</a> &amp;_filename );

protected:
    <a href="qstring.html">QString</a> filename;
    <a href="qfileinfo.html">QFileInfo</a> fileinfo;

    void setupTab1();
    void setupTab2();
    void setupTab3();

};

#endif
</pre>

<p> <hr>
<p> Implementation:
<p> <pre>/****************************************************************************
** $Id:  qt/tabdialog.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 "tabdialog.h"

#include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;
#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
#include &lt;<a href="qlineedit-h.html">qlineedit.h</a>&gt;
#include &lt;<a href="qdatetime-h.html">qdatetime.h</a>&gt;
#include &lt;<a href="qbuttongroup-h.html">qbuttongroup.h</a>&gt;
#include &lt;<a href="qcheckbox-h.html">qcheckbox.h</a>&gt;
#include &lt;<a href="qlistbox-h.html">qlistbox.h</a>&gt;
#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;

<a name="f201"></a>TabDialog::TabDialog( <a href="qwidget.html">QWidget</a> *parent, const char *name, const <a href="qstring.html">QString</a> &amp;_filename )
    : <a href="qtabdialog.html">QTabDialog</a>( parent, name ), filename( _filename ), fileinfo( filename )
{
    setupTab1();
    setupTab2();
    setupTab3();

    <a href="qobject.html#connect">connect</a>( this, SIGNAL( <a href="qtabdialog.html#applyButtonPressed">applyButtonPressed</a>() ), qApp, SLOT( <a href="qapplication.html#quit">quit</a>() ) );
}

void <a name="f202"></a>TabDialog::setupTab1()
{
    <a href="qvbox.html">QVBox</a> *tab1 = new <a href="qvbox.html">QVBox</a>( this );
<a name="x385"></a>    tab1-&gt;<a href="qframe.html#setMargin">setMargin</a>( 5 );

    (void)new <a href="qlabel.html">QLabel</a>( "Filename:", tab1 );
    <a href="qlineedit.html">QLineEdit</a> *fname = new <a href="qlineedit.html">QLineEdit</a>( filename, tab1 );
    fname-&gt;<a href="qwidget.html#setFocus">setFocus</a>();

    (void)new <a href="qlabel.html">QLabel</a>( "Path:", tab1 );
    <a href="qlabel.html">QLabel</a> *path = new <a href="qlabel.html">QLabel</a>( fileinfo.dirPath( TRUE ), tab1 );
<a name="x384"></a>    path-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    (void)new <a href="qlabel.html">QLabel</a>( "Size:", tab1 );
    <a href="qlabel.html">QLabel</a> *size = new <a href="qlabel.html">QLabel</a>( QString( "%1 KB" ).arg( fileinfo.size() ), tab1 );
    size-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    (void)new <a href="qlabel.html">QLabel</a>( "Last Read:", tab1 );
    <a href="qlabel.html">QLabel</a> *lread = new <a href="qlabel.html">QLabel</a>( fileinfo.lastRead().toString(), tab1 );
    lread-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    (void)new <a href="qlabel.html">QLabel</a>( "Last Modified:", tab1 );
    <a href="qlabel.html">QLabel</a> *lmodif = new <a href="qlabel.html">QLabel</a>( fileinfo.lastModified().toString(), tab1 );
    lmodif-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    <a href="qtabdialog.html#addTab">addTab</a>( tab1, "General" );
}

void <a name="f203"></a>TabDialog::setupTab2()
{
    <a href="qvbox.html">QVBox</a> *tab2 = new <a href="qvbox.html">QVBox</a>( this );
    tab2-&gt;<a href="qframe.html#setMargin">setMargin</a>( 5 );

    <a href="qbuttongroup.html">QButtonGroup</a> *bg = new <a href="qbuttongroup.html">QButtonGroup</a>( 1, QGroupBox::Horizontal, "Permissions", tab2 );

    <a href="qcheckbox.html">QCheckBox</a> *readable = new <a href="qcheckbox.html">QCheckBox</a>( "Readable", bg );
    if ( fileinfo.isReadable() )
<a name="x383"></a>        readable-&gt;<a href="qcheckbox.html#setChecked">setChecked</a>( TRUE );

    <a href="qcheckbox.html">QCheckBox</a> *writable = new <a href="qcheckbox.html">QCheckBox</a>( "Writeable", bg );
    if ( fileinfo.isWritable() )
        writable-&gt;<a href="qcheckbox.html#setChecked">setChecked</a>( TRUE );

    <a href="qcheckbox.html">QCheckBox</a> *executable = new <a href="qcheckbox.html">QCheckBox</a>( "Executable", bg );
    if ( fileinfo.isExecutable() )
        executable-&gt;<a href="qcheckbox.html#setChecked">setChecked</a>( TRUE );

    <a href="qbuttongroup.html">QButtonGroup</a> *bg2 = new <a href="qbuttongroup.html">QButtonGroup</a>( 2, QGroupBox::Horizontal, "Owner", tab2 );

    (void)new <a href="qlabel.html">QLabel</a>( "Owner", bg2 );
    <a href="qlabel.html">QLabel</a> *owner = new <a href="qlabel.html">QLabel</a>( fileinfo.owner(), bg2 );
    owner-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    (void)new <a href="qlabel.html">QLabel</a>( "Group", bg2 );
    <a href="qlabel.html">QLabel</a> *group = new <a href="qlabel.html">QLabel</a>( fileinfo.group(), bg2 );
    group-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken );

    <a href="qtabdialog.html#addTab">addTab</a>( tab2, "Permissions" );
}

void <a name="f204"></a>TabDialog::setupTab3()
{
    <a href="qvbox.html">QVBox</a> *tab3 = new <a href="qvbox.html">QVBox</a>( this );
    tab3-&gt;<a href="qframe.html#setMargin">setMargin</a>( 5 );
<a name="x386"></a>    tab3-&gt;<a href="qhbox.html#setSpacing">setSpacing</a>( 5 );

    (void)new <a href="qlabel.html">QLabel</a>( QString( "Open %1 with:" ).arg( filename ), tab3 );

    <a href="qlistbox.html">QListBox</a> *prgs = new <a href="qlistbox.html">QListBox</a>( tab3 );
    for ( unsigned int i = 0; i &lt; 30; i++ ) {
        <a href="qstring.html">QString</a> prg = QString( "Application %1" ).arg( i );
<a name="x387"></a>        prgs-&gt;<a href="qlistbox.html#insertItem">insertItem</a>( prg );
    }
<a name="x388"></a>    prgs-&gt;<a href="qlistbox.html#setCurrentItem">setCurrentItem</a>( 3 );

    (void)new <a href="qcheckbox.html">QCheckBox</a>( QString( "Open files with the extension '%1' always with this application" ).arg( fileinfo.extension() ), tab3 );

    <a href="qtabdialog.html#addTab">addTab</a>( tab3, "Applications" );
}
</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 "tabdialog.h"
#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include &lt;<a href="qstring-h.html">qstring.h</a>&gt;

int main( int argc, char **argv )
{

    <a href="qapplication.html">QApplication</a> a( argc, argv );

    TabDialog tabdialog( 0, "tabdialog", QString( argc &lt; 2 ? "." : argv[1] ) );
    tabdialog.<a href="qwidget.html#resize">resize</a>( 450, 350 );
    tabdialog.<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Tabbed Dialog" );
    a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &amp;tabdialog );
<a name="x392"></a>    tabdialog.<a href="qdialog.html#show">show</a>();

    return a.<a href="qapplication.html#exec">exec</a>();
}
</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>