summaryrefslogtreecommitdiffstats
path: root/doc/html/tabdialog-example.html
blob: fd8288febbbf52d1320167b7f3a4478004e22249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/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"><!--
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.3.8   edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
**
** This file is part of an example program for TQt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#ifndef TABDIALOG_H
#define TABDIALOG_H

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

class TabDialog : public <a href="ntqtabdialog.html">TQTabDialog</a>
{
    <a href="metaobjects.html#TQ_OBJECT">TQ_OBJECT</a>

public:
    TabDialog( <a href="tqwidget.html">TQWidget</a> *parent, const char *name, const <a href="tqstring.html">TQString</a> &amp;_filename );

protected:
    <a href="tqstring.html">TQString</a> filename;
    <a href="ntqfileinfo.html">TQFileInfo</a> fileinfo;

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

};

#endif
</pre>

<p> <hr>
<p> Implementation:
<p> <pre>/****************************************************************************
** $Id: qt/tabdialog.cpp   3.3.8   edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
**
** This file is part of an example program for TQt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include "tabdialog.h"

#include &lt;<a href="qvbox-h.html">ntqvbox.h</a>&gt;
#include &lt;<a href="qlabel-h.html">ntqlabel.h</a>&gt;
#include &lt;<a href="qlineedit-h.html">ntqlineedit.h</a>&gt;
#include &lt;<a href="qdatetime-h.html">ntqdatetime.h</a>&gt;
#include &lt;<a href="qbuttongroup-h.html">ntqbuttongroup.h</a>&gt;
#include &lt;<a href="qcheckbox-h.html">ntqcheckbox.h</a>&gt;
#include &lt;<a href="qlistbox-h.html">ntqlistbox.h</a>&gt;
#include &lt;<a href="qapplication-h.html">ntqapplication.h</a>&gt;

<a name="f200"></a>TabDialog::TabDialog( <a href="tqwidget.html">TQWidget</a> *parent, const char *name, const <a href="tqstring.html">TQString</a> &amp;_filename )
    : <a href="ntqtabdialog.html">TQTabDialog</a>( parent, name ), filename( _filename ), fileinfo( filename )
{
    setupTab1();
    setupTab2();
    setupTab3();

    <a href="tqobject.html#connect">connect</a>( this, TQ_SIGNAL( <a href="ntqtabdialog.html#applyButtonPressed">applyButtonPressed</a>() ), tqApp, TQ_SLOT( <a href="ntqapplication.html#quit">quit</a>() ) );
}

void <a name="f201"></a>TabDialog::setupTab1()
{
    <a href="ntqvbox.html">TQVBox</a> *tab1 = new <a href="ntqvbox.html">TQVBox</a>( this );
<a name="x53"></a>    tab1-&gt;<a href="ntqframe.html#setMargin">setMargin</a>( 5 );

    (void)new <a href="ntqlabel.html">TQLabel</a>( "Filename:", tab1 );
    <a href="ntqlineedit.html">TQLineEdit</a> *fname = new <a href="ntqlineedit.html">TQLineEdit</a>( filename, tab1 );
    fname-&gt;<a href="tqwidget.html#setFocus">setFocus</a>();

    (void)new <a href="ntqlabel.html">TQLabel</a>( "Path:", tab1 );
    <a href="ntqlabel.html">TQLabel</a> *path = new <a href="ntqlabel.html">TQLabel</a>( fileinfo.dirPath( TRUE ), tab1 );
<a name="x52"></a>    path-&gt;<a href="ntqframe.html#setFrameStyle">setFrameStyle</a>( TQFrame::Panel | TQFrame::Sunken );

    (void)new <a href="ntqlabel.html">TQLabel</a>( "Size:", tab1 );
    ulong kb = (ulong)(fileinfo.size()/1024);
    <a href="ntqlabel.html">TQLabel</a> *size = new <a href="ntqlabel.html">TQLabel</a>( TQString( "%1 KB" ).arg( kb ), tab1 );
    size-&gt;<a href="ntqframe.html#setFrameStyle">setFrameStyle</a>( TQFrame::Panel | TQFrame::Sunken );

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

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

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

void <a name="f202"></a>TabDialog::setupTab2()
{
    <a href="ntqvbox.html">TQVBox</a> *tab2 = new <a href="ntqvbox.html">TQVBox</a>( this );
    tab2-&gt;<a href="ntqframe.html#setMargin">setMargin</a>( 5 );

    <a href="ntqbuttongroup.html">TQButtonGroup</a> *bg = new <a href="ntqbuttongroup.html">TQButtonGroup</a>( 1, TQGroupBox::Horizontal, "Permissions", tab2 );

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

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

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

    <a href="ntqbuttongroup.html">TQButtonGroup</a> *bg2 = new <a href="ntqbuttongroup.html">TQButtonGroup</a>( 2, TQGroupBox::Horizontal, "Owner", tab2 );

    (void)new <a href="ntqlabel.html">TQLabel</a>( "Owner", bg2 );
    <a href="ntqlabel.html">TQLabel</a> *owner = new <a href="ntqlabel.html">TQLabel</a>( fileinfo.owner(), bg2 );
    owner-&gt;<a href="ntqframe.html#setFrameStyle">setFrameStyle</a>( TQFrame::Panel | TQFrame::Sunken );

    (void)new <a href="ntqlabel.html">TQLabel</a>( "Group", bg2 );
    <a href="ntqlabel.html">TQLabel</a> *group = new <a href="ntqlabel.html">TQLabel</a>( fileinfo.group(), bg2 );
    group-&gt;<a href="ntqframe.html#setFrameStyle">setFrameStyle</a>( TQFrame::Panel | TQFrame::Sunken );

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

void <a name="f203"></a>TabDialog::setupTab3()
{
    <a href="ntqvbox.html">TQVBox</a> *tab3 = new <a href="ntqvbox.html">TQVBox</a>( this );
    tab3-&gt;<a href="ntqframe.html#setMargin">setMargin</a>( 5 );
<a name="x54"></a>    tab3-&gt;<a href="ntqhbox.html#setSpacing">setSpacing</a>( 5 );

    (void)new <a href="ntqlabel.html">TQLabel</a>( TQString( "Open %1 with:" ).arg( filename ), tab3 );

    <a href="ntqlistbox.html">TQListBox</a> *prgs = new <a href="ntqlistbox.html">TQListBox</a>( tab3 );
    for ( unsigned int i = 0; i &lt; 30; i++ ) {
        <a href="tqstring.html">TQString</a> prg = TQString( "Application %1" ).arg( i );
<a name="x55"></a>        prgs-&gt;<a href="ntqlistbox.html#insertItem">insertItem</a>( prg );
    }
<a name="x56"></a>    prgs-&gt;<a href="ntqlistbox.html#setCurrentItem">setCurrentItem</a>( 3 );

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

    <a href="ntqtabdialog.html#addTab">addTab</a>( tab3, "Applications" );
}
</pre>

<p> <hr>
<p> Main:
<p> <pre>/****************************************************************************
** $Id: qt/main.cpp   3.3.8   edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
**
** This file is part of an example program for TQt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

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

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

    <a href="ntqapplication.html">TQApplication</a> a( argc, argv );

    TabDialog tabdialog( 0, "tabdialog", TQString( argc &lt; 2 ? "." : argv[1] ) );
<a name="x60"></a>    tabdialog.<a href="tqwidget.html#resize">resize</a>( 450, 350 );
    tabdialog.<a href="tqwidget.html#setCaption">setCaption</a>( "TQt Example - Tabbed Dialog" );
    a.<a href="ntqapplication.html#setMainWidget">setMainWidget</a>( &amp;tabdialog );
<a name="x61"></a>    tabdialog.<a href="ntqdialog.html#show">show</a>();

    return a.<a href="ntqapplication.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; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>