~oif-team/ubuntu/natty/qt4-x11/xi2.1

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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Qt 4.0: main.cpp Example File (activeqt/simple/main.cpp)</title>
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">main.cpp Example File<br /><small><small>activeqt/simple/main.cpp</small></small></h1>
<pre>&nbsp;   /****************************************************************************
    **
    ** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
    **
    ** This file is part of the documentation of the Qt Toolkit.
    **
    ** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
    **
    ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    **
    ****************************************************************************/

    #include &lt;qapplication.h&gt;
    #include &lt;qlayout.h&gt;
    #include &lt;qslider.h&gt;
    #include &lt;qlcdnumber.h&gt;
    #include &lt;qlineedit.h&gt;
    #include &lt;qmessagebox.h&gt;

    #include &lt;qaxbindable.h&gt;
    #include &lt;qaxfactory.h&gt;

    class QSimpleAX : public QWidget, public QAxBindable
    {
        Q_OBJECT
        Q_PROPERTY( QString text READ text WRITE setText )
        Q_PROPERTY( int value READ value WRITE setValue )
    public:
        QSimpleAX(QWidget *parent = 0)
        : QWidget(parent)
        {
            QVBoxLayout *vbox = new QVBoxLayout( this );

            slider = new QSlider( Qt::Horizontal, this );
            LCD = new QLCDNumber( 3, this );
            edit = new QLineEdit( this );

            connect( slider, SIGNAL( valueChanged( int ) ), this, SLOT( setValue(int) ) );
            connect( edit, SIGNAL(textChanged(const QString&amp;)), this, SLOT(setText(const QString&amp;)) );

            vbox-&gt;addWidget( slider );
            vbox-&gt;addWidget( LCD );
            vbox-&gt;addWidget( edit );
        }

        QString text() const
        {
            return edit-&gt;text();
        }
        int value() const
        {
            return slider-&gt;value();
        }

    signals:
        void someSignal();
        void valueChanged(int);
        void textChanged(const QString&amp;);

    public slots:
        void setText( const QString &amp;string )
        {
            if ( !requestPropertyChange( &quot;text&quot; ) )
                return;

            edit-&gt;blockSignals( TRUE );
            edit-&gt;setText( string );
            edit-&gt;blockSignals( FALSE );
            emit someSignal();
            emit textChanged( string );

            propertyChanged( &quot;text&quot; );
        }
        void about()
        {
            QMessageBox::information( this, &quot;About QSimpleAX&quot;, &quot;This is a Qt widget, and this slot has been\n&quot;
                                                              &quot;called through ActiveX/OLE automation!&quot; );
        }
        void setValue( int i )
        {
            if ( !requestPropertyChange( &quot;value&quot; ) )
                return;
            slider-&gt;blockSignals( TRUE );
            slider-&gt;setValue( i );
            slider-&gt;blockSignals( FALSE );
            LCD-&gt;display( i );
            emit valueChanged( i );

            propertyChanged( &quot;value&quot; );
        }

    private:
        QSlider *slider;
        QLCDNumber *LCD;
        QLineEdit *edit;
    };

    #include &quot;main.moc&quot;

    QAXFACTORY_DEFAULT(QSimpleAX,
               &quot;{DF16845C-92CD-4AAB-A982-EB9840E74669}&quot;,
               &quot;{616F620B-91C5-4410-A74E-6B81C76FFFE0}&quot;,
               &quot;{E1816BBA-BF5D-4A31-9855-D6BA432055FF}&quot;,
               &quot;{EC08F8FC-2754-47AB-8EFE-56A54057F34E}&quot;,
               &quot;{A095BA0C-224F-4933-A458-2DD7F6B85D8F}&quot;)</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
</tr></table></div></address></body>
</html>