source: trunk/examples/dragdrop/main.cpp

Last change on this file 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** Ritual main() for Qt applications
5**
6** Copyright (C) 1996 by Trolltech AS. All rights reserved.
7**
8** This file is part of an example program for Qt. This example
9** program may be used, distributed and modified without limitation.
10**
11*****************************************************************************/
12
13#include <qapplication.h>
14#include "dropsite.h"
15#include "secret.h"
16#include <qlayout.h>
17#include <qcombobox.h>
18#include <qlabel.h>
19#include <qpixmap.h>
20
21static void addStuff( QWidget * parent, bool image, bool secret = FALSE )
22{
23 QVBoxLayout * tll = new QVBoxLayout( parent, 10 );
24 DropSite * d = new DropSite( parent );
25 d->setFrameStyle( QFrame::Sunken + QFrame::WinPanel );
26 tll->addWidget( d );
27 if ( image ) {
28 QPixmap stuff;
29 if ( !stuff.load( "trolltech.bmp" ) ) {
30 stuff = QPixmap(20,20);
31 stuff.fill(Qt::green);
32 }
33 d->setPixmap( stuff );
34 } else {
35 d->setText("Drag and Drop");
36 }
37 d->setFont(QFont("Helvetica",18));
38 if ( secret ) {
39 SecretSource *s = new SecretSource( 42, parent );
40 tll->addWidget( s );
41 }
42
43 QLabel * format = new QLabel( "\n\n\n\nNone\n\n\n\n", parent );
44 tll->addWidget( format );
45 tll->activate();
46 parent->resize( parent->sizeHint() );
47
48 QObject::connect( d, SIGNAL(message(const QString&)),
49 format, SLOT(setText(const QString&)) );
50}
51
52
53int main( int argc, char ** argv )
54{
55 QApplication a( argc, argv );
56
57 QWidget mw;
58 addStuff( &mw, TRUE );
59 mw.setCaption( "Qt Example - Drag and Drop" );
60 mw.show();
61
62 QWidget mw2;
63 addStuff( &mw2, FALSE );
64 mw2.setCaption( "Qt Example - Drag and Drop" );
65 mw2.show();
66
67 QWidget mw3;
68 addStuff( &mw3, TRUE, TRUE );
69 mw3.setCaption( "Qt Example - Drag and Drop" );
70 mw3.show();
71
72 QObject::connect(qApp,SIGNAL(lastWindowClosed()),qApp,SLOT(quit()));
73 return a.exec();
74}
Note: See TracBrowser for help on using the repository browser.