summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_plugins-howto.qdoc
blob: 45c869087a122153d050a280685b1d3136ce1afb (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
//! [0]
class MyStylePlugin : public QStylePlugin
{
public:
    QStringList keys() const;
    QStyle *create(const QString &key);
};
//! [0]


//! [1]
#include "mystyleplugin.h"

QStringList MyStylePlugin::keys() const
{
    return QStringList() << "MyStyle";
}

QStyle *MyStylePlugin::create(const QString &key)
{
    if (key.toLower() == "mystyle")
        return new MyStyle;
    return 0;
}

Q_EXPORT_PLUGIN2(pnp_mystyleplugin, MyStylePlugin)
//! [1]


//! [2]
QApplication::setStyle(QStyleFactory::create("MyStyle"));
//! [2]


//! [3]
CONFIG += release
//! [3]


//! [4]
#include <QApplication>
#include <QtPlugin>

Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qkrcodecs)

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    ...
    return app.exec();
}
//! [4]


//! [5]
QTPLUGIN     += qjpeg \
                qgif \
                qkrcodecs
//! [5]


//! [6]
HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug
HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false
//! [6]