source: trunk/doc/html/iconview-example.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 5.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/examples/iconview/iconview.doc:4 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Iconview</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Iconview</h1>
33
34
35<p>
36This example implements a flexible icon view which can store
37lots of icon items. It supports Drag&Drop, different selection modes,
38view modes, rubberband selection, etc.
39<p> Main:
40<p> <pre>/****************************************************************************
41** $Id: iconview-example.html 2051 2007-02-21 10:04:20Z chehrlic $
42**
43** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
44**
45** This file is part of an example program for Qt. This example
46** program may be used, distributed and modified without limitation.
47**
48*****************************************************************************/
49
50#include &lt;<a href="qiconview-h.html">qiconview.h</a>&gt;
51#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
52#include &lt;<a href="qdragobject-h.html">qdragobject.h</a>&gt;
53#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;
54#include &lt;<a href="qiconset-h.html">qiconset.h</a>&gt;
55
56#include &lt;<a href="qmime-h.html">qmime.h</a>&gt;
57#include &lt;stdio.h&gt;
58
59class ListenDND : public <a href="qobject.html">QObject</a>
60{
61 <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
62
63public:
64 ListenDND( <a href="qwidget.html">QWidget</a> *w )
65 : view( w )
66 {}
67
68public slots:
69 void dropped( <a href="qdropevent.html">QDropEvent</a> *mime ) {
70 <a href="qapplication.html#qDebug">qDebug</a>( "Dropped Mimesource %p into the view %p", mime, view );
71 <a href="qapplication.html#qDebug">qDebug</a>( " Formats:" );
72 int i = 0;
73<a name="x1454"></a> const char *str = mime-&gt;<a href="qdropevent.html#format">format</a>( i );
74 <a href="qapplication.html#qDebug">qDebug</a>( " %s", str );
75 while ( str ) {
76 <a href="qapplication.html#qDebug">qDebug</a>( " %s", str );
77 str = mime-&gt;<a href="qdropevent.html#format">format</a>( ++i );
78 }
79 };
80 void moved() {
81 <a href="qapplication.html#qDebug">qDebug</a>( "All selected items were moved to another widget" );
82 }
83
84protected:
85 <a href="qwidget.html">QWidget</a> *view;
86
87};
88
89int main( int argc, char **argv )
90{
91 <a href="qapplication.html">QApplication</a> a( argc, argv );
92
93 <a href="qiconview.html">QIconView</a> qiconview;
94<a name="x1457"></a> qiconview.<a href="qiconview.html#setSelectionMode">setSelectionMode</a>( QIconView::Extended );
95
96 for ( unsigned int i = 0; i &lt; 3000; i++ ) {
97 <a href="qiconviewitem.html">QIconViewItem</a> *item = new <a href="qiconviewitem.html">QIconViewItem</a>( &amp;qiconview, QString( "Item %1" ).arg( i + 1 ) );
98<a name="x1459"></a> item-&gt;<a href="qiconviewitem.html#setRenameEnabled">setRenameEnabled</a>( TRUE );
99 }
100
101 qiconview.<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Iconview" );
102
103 ListenDND listen_dnd( &amp;qiconview );
104<a name="x1460"></a><a name="x1455"></a> QObject::<a href="qobject.html#connect">connect</a>( &amp;qiconview, SIGNAL( <a href="qiconview.html#dropped">dropped</a>( <a href="qdropevent.html">QDropEvent</a> *, const <a href="qvaluelist.html">QValueList</a>&lt;QIconDragItem&gt; &amp; ) ),
105 &amp;listen_dnd, SLOT( dropped( <a href="qdropevent.html">QDropEvent</a> * ) ) );
106<a name="x1456"></a> QObject::<a href="qobject.html#connect">connect</a>( &amp;qiconview, SIGNAL( <a href="qiconview.html#moved">moved</a>() ), &amp;listen_dnd, SLOT( moved() ) );
107
108 a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &amp;qiconview );
109<a name="x1462"></a> qiconview.<a href="qwidget.html#show">show</a>();
110<a name="x1461"></a><a name="x1458"></a> qiconview.<a href="qwidget.html#resize">resize</a>( qiconview.<a href="qwidget.html#sizeHint">sizeHint</a>() );
111
112 return a.<a href="qapplication.html#exec">exec</a>();
113}
114
115#include "main.moc"
116</pre>
117
118<p>See also <a href="examples.html">Examples</a>.
119
120<!-- eof -->
121<p><address><hr><div align=center>
122<table width=100% cellspacing=0 border=0><tr>
123<td>Copyright &copy; 2007
124<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
125<td align=right><div align=right>Qt 3.3.8</div>
126</table></div></address></body>
127</html>
Note: See TracBrowser for help on using the repository browser.