source: trunk/examples/iconview/main.cpp@ 168

Last change on this file since 168 was 160, checked in by dmik, 19 years ago

Imported table and iconview modules and a bunch of dependent examples from the official release 3.3.1 from Trolltech.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/****************************************************************************
2** $Id: main.cpp 160 2006-12-11 20:15:57Z dmik $
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9*****************************************************************************/
10
11#include <qiconview.h>
12#include <qapplication.h>
13#include <qdragobject.h>
14#include <qpixmap.h>
15#include <qiconset.h>
16
17#include <qmime.h>
18#include <stdio.h>
19
20class ListenDND : public QObject
21{
22 Q_OBJECT
23
24public:
25 ListenDND( QWidget *w )
26 : view( w )
27 {}
28
29public slots:
30 void dropped( QDropEvent *mime ) {
31 qDebug( "Dropped Mimesource %p into the view %p", mime, view );
32 qDebug( " Formats:" );
33 int i = 0;
34 const char *str = mime->format( i );
35 qDebug( " %s", str );
36 while ( str ) {
37 qDebug( " %s", str );
38 str = mime->format( ++i );
39 }
40 };
41 void moved() {
42 qDebug( "All selected items were moved to another widget" );
43 }
44
45protected:
46 QWidget *view;
47
48};
49
50int main( int argc, char **argv )
51{
52 QApplication a( argc, argv );
53
54 QIconView qiconview;
55 qiconview.setSelectionMode( QIconView::Extended );
56
57 for ( unsigned int i = 0; i < 3000; i++ ) {
58 QIconViewItem *item = new QIconViewItem( &qiconview, QString( "Item %1" ).arg( i + 1 ) );
59 item->setRenameEnabled( TRUE );
60 }
61
62 qiconview.setCaption( "Qt Example - Iconview" );
63
64 ListenDND listen_dnd( &qiconview );
65 QObject::connect( &qiconview, SIGNAL( dropped( QDropEvent *, const QValueList<QIconDragItem> & ) ),
66 &listen_dnd, SLOT( dropped( QDropEvent * ) ) );
67 QObject::connect( &qiconview, SIGNAL( moved() ), &listen_dnd, SLOT( moved() ) );
68
69 a.setMainWidget( &qiconview );
70 qiconview.show();
71 qiconview.resize( qiconview.sizeHint() );
72
73 return a.exec();
74}
75
76#include "main.moc"
Note: See TracBrowser for help on using the repository browser.