@@ -1,28 +1,28 | |||
|
1 |
from PythonQt import |
|
|
1 | from PythonQt import QtCore, QtGui, example | |
|
2 | 2 | |
|
3 | 3 | # call our new constructor of QSize |
|
4 | size = QSize(QPoint(1,2)); | |
|
4 | size = QtCore.QSize(QtCore.QPoint(1,2)); | |
|
5 | 5 | |
|
6 | 6 | # call our new QPushButton constructor |
|
7 | button = QPushButton("sometext"); | |
|
7 | button = QtGui.QPushButton("sometext"); | |
|
8 | 8 | |
|
9 | 9 | # call the move slot (overload1) |
|
10 | button.move(QPoint(0,0)) | |
|
10 | button.move(QtCore.QPoint(0,0)) | |
|
11 | 11 | |
|
12 | 12 | # call the move slot (overload2) |
|
13 | 13 | button.move(0,0) |
|
14 | 14 | |
|
15 | 15 | # call the static method |
|
16 | print QWidget.mouseGrabber(); | |
|
16 | print QtGui.QWidget.mouseGrabber(); | |
|
17 | 17 | |
|
18 | 18 | # create a CPP object via constructor |
|
19 | yourCpp = YourCPPObject(2,11.5) | |
|
19 | yourCpp = example.YourCPPObject(2,11.5) | |
|
20 | 20 | |
|
21 | 21 | # call the wrapped method on CPP object |
|
22 | 22 | print yourCpp.doSomething(3); |
|
23 | 23 | |
|
24 | 24 | # show slots available on yourCpp |
|
25 | 25 | print dir(yourCpp) |
|
26 | 26 | |
|
27 | 27 | # destructor will be called: |
|
28 | 28 | yourCpp = None |
@@ -1,68 +1,68 | |||
|
1 | 1 | /* |
|
2 | 2 | * |
|
3 | 3 | * Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved. |
|
4 | 4 | * |
|
5 | 5 | * This library is free software; you can redistribute it and/or |
|
6 | 6 | * modify it under the terms of the GNU Lesser General Public |
|
7 | 7 | * License as published by the Free Software Foundation; either |
|
8 | 8 | * version 2.1 of the License, or (at your option) any later version. |
|
9 | 9 | * |
|
10 | 10 | * This library is distributed in the hope that it will be useful, |
|
11 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | 13 | * Lesser General Public License for more details. |
|
14 | 14 | * |
|
15 | 15 | * Further, this software is distributed without any warranty that it is |
|
16 | 16 | * free of the rightful claim of any third person regarding infringement |
|
17 | 17 | * or the like. Any license provided herein, whether implied or |
|
18 | 18 | * otherwise, applies only to this software file. Patent licenses, if |
|
19 | 19 | * any, provided herein do not apply to combinations of this program with |
|
20 | 20 | * other software, or any other product whatsoever. |
|
21 | 21 | * |
|
22 | 22 | * You should have received a copy of the GNU Lesser General Public |
|
23 | 23 | * License along with this library; if not, write to the Free Software |
|
24 | 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 | 25 | * |
|
26 | 26 | * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29, |
|
27 | 27 | * 28359 Bremen, Germany or: |
|
28 | 28 | * |
|
29 | 29 | * http://www.mevis.de |
|
30 | 30 | * |
|
31 | 31 | */ |
|
32 | 32 | |
|
33 | 33 | //---------------------------------------------------------------------------------- |
|
34 | 34 | /*! |
|
35 | 35 | // \file PyGuiExample.cpp |
|
36 | 36 | // \author Florian Link |
|
37 | 37 | // \author Last changed by $Author: florian $ |
|
38 | 38 | // \date 2007-04 |
|
39 | 39 | */ |
|
40 | 40 | //---------------------------------------------------------------------------------- |
|
41 | 41 | |
|
42 | 42 | #include "PythonQt.h" |
|
43 | 43 | #include "gui/PythonQtScriptingConsole.h" |
|
44 | 44 | #include "PyExampleDecorators.h" |
|
45 | 45 | |
|
46 | 46 | #include <QApplication> |
|
47 | 47 | |
|
48 | 48 | int main( int argc, char **argv ) |
|
49 | 49 | { |
|
50 | 50 | QApplication qapp(argc, argv); |
|
51 | 51 | |
|
52 | 52 | PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); |
|
53 | 53 | |
|
54 | 54 | PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); |
|
55 | 55 | PythonQtScriptingConsole console(NULL, mainContext); |
|
56 | 56 | |
|
57 | 57 | PythonQt::self()->addDecorators(new PyExampleDecorators()); |
|
58 | PythonQt::self()->registerClass(&QPushButton::staticMetaObject); | |
|
59 | PythonQt::self()->registerCPPClass("YourCPPObject"); | |
|
58 | PythonQt::self()->registerClass(&QPushButton::staticMetaObject, "QtGui"); | |
|
59 | PythonQt::self()->registerCPPClass("YourCPPObject","", "example"); | |
|
60 | 60 | |
|
61 | 61 | mainContext.evalFile(":example.py"); |
|
62 | 62 | |
|
63 | 63 | console.appendCommandPrompt(); |
|
64 | 64 | console.show(); |
|
65 | 65 | |
|
66 | 66 | return qapp.exec(); |
|
67 | 67 | } |
|
68 | 68 |
General Comments 0
You need to be logged in to leave comments.
Login now