├── README.md ├── tutOff ├── __pycache__ │ └── myQML.cpython-34.pyc ├── deployment.pri ├── main.cpp ├── main.py ├── main.qml ├── myQML.py ├── qml.qrc ├── tutOff.pro └── tutOff.pro.user ├── tutOff2 ├── EllipseItem.py ├── __pycache__ │ └── EllipseItem.cpython-34.pyc ├── deployment.pri ├── main.cpp ├── main.py ├── main.qml ├── qml.qrc ├── tutOff2.pro └── tutOff2.pro.user ├── tutOff2_InetVersion ├── ItFuckingWorks ├── deployment.pri ├── main.cpp ├── main.py ├── main.qml ├── qml.qrc ├── tutOff2_InetVersion.pro └── tutOff2_InetVersion.pro.user ├── tutOff3_property ├── THisWorksTooYeah!!!!!!! ├── deployment.pri ├── main.cpp ├── main.py ├── main.qml ├── qml.qrc ├── tutOff3_property.pro └── tutOff3_property.pro.user └── tutOff4_signals ├── deployment.pri ├── main.cpp ├── main.py ├── main.qml ├── qml.qrc ├── tutOff4_signals.pro └── tutOff4_signals.pro.user /README.md: -------------------------------------------------------------------------------- 1 | # pyQt5-QML-examples 2 | -------------------------------------------------------------------------------- /tutOff/__pycache__/myQML.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hovo1990/pyQt5-QML-examples/7a0f39b2a7b6e9b9e3c16a01c4611782a1e4a01f/tutOff/__pycache__/myQML.cpython-34.pyc -------------------------------------------------------------------------------- /tutOff/deployment.pri: -------------------------------------------------------------------------------- 1 | android-no-sdk { 2 | target.path = /data/user/qt 3 | export(target.path) 4 | INSTALLS += target 5 | } else:android { 6 | x86 { 7 | target.path = /libs/x86 8 | } else: armeabi-v7a { 9 | target.path = /libs/armeabi-v7a 10 | } else { 11 | target.path = /libs/armeabi 12 | } 13 | export(target.path) 14 | INSTALLS += target 15 | } else:unix { 16 | isEmpty(target.path) { 17 | qnx { 18 | target.path = /tmp/$${TARGET}/bin 19 | } else { 20 | target.path = /opt/$${TARGET}/bin 21 | } 22 | export(target.path) 23 | } 24 | INSTALLS += target 25 | } 26 | 27 | export(INSTALLS) 28 | -------------------------------------------------------------------------------- /tutOff/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /tutOff/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # -*- coding: utf-8 -*- 5 | ## -*- coding: utf-8 -*- 6 | ## -*- coding: utf-8 -*- 7 | #import sys 8 | #from PyQt5.QtCore import QObject, QUrl, Qt 9 | #from PyQt5.QtWidgets import QApplication 10 | #from PyQt5.QtQml import QQmlApplicationEngine 11 | 12 | ##THis fucking works mate 13 | 14 | 15 | 16 | import sys 17 | import os.path 18 | 19 | from PyQt5.QtCore import QObject, Qt 20 | from PyQt5.QtCore import QUrl 21 | from PyQt5.QtGui import QGuiApplication 22 | from PyQt5.QtQuick import QQuickView 23 | import myQML 24 | 25 | app = QGuiApplication(sys.argv) 26 | 27 | 28 | 29 | print('-----------------------------------------------------------------------') 30 | 31 | 32 | qmlFile = 'main.qml' 33 | 34 | #qmlFile = "qrc:data/" 35 | 36 | 37 | view = QQuickView() 38 | view.setResizeMode(QQuickView.SizeRootObjectToView) 39 | view.engine().quit.connect(app.quit) 40 | 41 | engine = view.engine() 42 | view.setSource(QUrl(qmlFile)) # putting at the end didn't solve referenceError 'This is supposed to solve all referenceErrors 43 | 44 | 45 | 46 | view.show() 47 | sys.exit(app.exec_()) 48 | 49 | 50 | -------------------------------------------------------------------------------- /tutOff/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | //import QtQuick.Window 2.1 3 | 4 | Rectangle { 5 | visible: true 6 | width: 360 7 | height: 360 8 | 9 | MouseArea { 10 | anchors.fill: parent 11 | onClicked: { 12 | Qt.quit(); 13 | } 14 | } 15 | 16 | Text { 17 | text: qsTr("Hello World") 18 | font.pixelSize: 20 19 | anchors.centerIn: parent 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutOff/myQML.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created: Wed Jan 28 19:46:03 2015 6 | # by: The Resource Compiler for PyQt (Qt v5.4.0) 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt5 import QtCore 11 | 12 | qt_resource_data = b"\ 13 | \x00\x00\x01\x2e\ 14 | \x69\ 15 | \x6d\x70\x6f\x72\x74\x20\x51\x74\x51\x75\x69\x63\x6b\x20\x32\x2e\ 16 | \x32\x0a\x2f\x2f\x69\x6d\x70\x6f\x72\x74\x20\x51\x74\x51\x75\x69\ 17 | \x63\x6b\x2e\x57\x69\x6e\x64\x6f\x77\x20\x32\x2e\x31\x0a\x0a\x52\ 18 | \x65\x63\x74\x61\x6e\x67\x6c\x65\x20\x7b\x0a\x20\x20\x20\x20\x76\ 19 | \x69\x73\x69\x62\x6c\x65\x3a\x20\x74\x72\x75\x65\x0a\x20\x20\x20\ 20 | \x20\x77\x69\x64\x74\x68\x3a\x20\x33\x36\x30\x0a\x20\x20\x20\x20\ 21 | \x68\x65\x69\x67\x68\x74\x3a\x20\x33\x36\x30\x0a\x0a\x20\x20\x20\ 22 | \x20\x4d\x6f\x75\x73\x65\x41\x72\x65\x61\x20\x7b\x0a\x20\x20\x20\ 23 | \x20\x20\x20\x20\x20\x61\x6e\x63\x68\x6f\x72\x73\x2e\x66\x69\x6c\ 24 | \x6c\x3a\x20\x70\x61\x72\x65\x6e\x74\x0a\x20\x20\x20\x20\x20\x20\ 25 | \x20\x20\x6f\x6e\x43\x6c\x69\x63\x6b\x65\x64\x3a\x20\x7b\x0a\x20\ 26 | \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x51\x74\x2e\x71\x75\ 27 | \x69\x74\x28\x29\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x7d\x0a\ 28 | \x20\x20\x20\x20\x7d\x0a\x0a\x20\x20\x20\x20\x54\x65\x78\x74\x20\ 29 | \x7b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x74\x65\x78\x74\x3a\x20\ 30 | \x71\x73\x54\x72\x28\x22\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\ 31 | \x64\x22\x29\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x61\x6e\x63\x68\ 32 | \x6f\x72\x73\x2e\x63\x65\x6e\x74\x65\x72\x49\x6e\x3a\x20\x70\x61\ 33 | \x72\x65\x6e\x74\x0a\x20\x20\x20\x20\x7d\x0a\x7d\x0a\ 34 | " 35 | 36 | qt_resource_name = b"\ 37 | \x00\x08\ 38 | \x08\x01\x5a\x5c\ 39 | \x00\x6d\ 40 | \x00\x61\x00\x69\x00\x6e\x00\x2e\x00\x71\x00\x6d\x00\x6c\ 41 | " 42 | 43 | qt_resource_struct = b"\ 44 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 45 | \x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 46 | " 47 | 48 | def qInitResources(): 49 | QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) 50 | 51 | def qCleanupResources(): 52 | QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) 53 | 54 | qInitResources() 55 | -------------------------------------------------------------------------------- /tutOff/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutOff/tutOff.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | SOURCES += main.cpp 6 | 7 | RESOURCES += qml.qrc 8 | 9 | # Additional import path used to resolve QML modules in Qt Creator's code model 10 | QML_IMPORT_PATH = 11 | 12 | # Default rules for deployment. 13 | include(deployment.pri) 14 | 15 | DISTFILES += \ 16 | main.py 17 | -------------------------------------------------------------------------------- /tutOff/tutOff.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {a8c8ceca-ba1f-4cab-b29b-7b8cef94421b} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.4.0 GCC 64bit 62 | Desktop Qt 5.4.0 GCC 64bit 63 | qt.54.gcc_64_kit 64 | 0 65 | 0 66 | 0 67 | 68 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff-Desktop_Qt_5_4_0_GCC_64bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | true 76 | false 77 | 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | -w 88 | -r 89 | 90 | false 91 | 92 | 93 | 94 | 2 95 | Build 96 | 97 | ProjectExplorer.BuildSteps.Build 98 | 99 | 100 | 101 | true 102 | Make 103 | 104 | Qt4ProjectManager.MakeStep 105 | 106 | -w 107 | -r 108 | 109 | true 110 | clean 111 | 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff-Desktop_Qt_5_4_0_GCC_64bit-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | true 137 | 138 | false 139 | false 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | -w 148 | -r 149 | 150 | false 151 | 152 | 153 | 154 | 2 155 | Build 156 | 157 | ProjectExplorer.BuildSteps.Build 158 | 159 | 160 | 161 | true 162 | Make 163 | 164 | Qt4ProjectManager.MakeStep 165 | 166 | -w 167 | -r 168 | 169 | true 170 | clean 171 | 172 | 173 | 1 174 | Clean 175 | 176 | ProjectExplorer.BuildSteps.Clean 177 | 178 | 2 179 | false 180 | 181 | Release 182 | 183 | Qt4ProjectManager.Qt4BuildConfiguration 184 | 0 185 | true 186 | 187 | 2 188 | 189 | 190 | 0 191 | Deploy 192 | 193 | ProjectExplorer.BuildSteps.Deploy 194 | 195 | 1 196 | Deploy locally 197 | 198 | ProjectExplorer.DefaultDeployConfiguration 199 | 200 | 1 201 | 202 | 203 | 204 | false 205 | false 206 | false 207 | false 208 | true 209 | 0.01 210 | 10 211 | true 212 | 1 213 | 25 214 | 215 | 1 216 | true 217 | false 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | 2 238 | 239 | tutOff 240 | 241 | Qt4ProjectManager.Qt4RunConfiguration:/home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/tutOff/tutOff.pro 242 | 243 | tutOff.pro 244 | false 245 | false 246 | 247 | 3768 248 | false 249 | true 250 | false 251 | false 252 | true 253 | 254 | 1 255 | 256 | 257 | 258 | ProjectExplorer.Project.TargetCount 259 | 1 260 | 261 | 262 | ProjectExplorer.Project.Updater.FileVersion 263 | 18 264 | 265 | 266 | Version 267 | 18 268 | 269 | 270 | -------------------------------------------------------------------------------- /tutOff2/EllipseItem.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | try: 4 | from PySide import QtCore 5 | from PySide import QtWidgets 6 | except: 7 | from PyQt5.QtCore import pyqtSlot as Slot 8 | from PyQt5 import QtCore 9 | from PyQt5 import QtWidgets 10 | 11 | try: 12 | from PyQt5.QtGui import QPainter 13 | from PyQt5.QtWidgets import QStyleOptionGraphicsItem 14 | from PyQt5.QtWidgets import QWidget 15 | from PyQt5.QtWidgets import QGraphicsItem 16 | 17 | from PyQt5.QtQuick import QQuickItem 18 | from PyQt5.QtQuick import QQuickPaintedItem 19 | except Exception as e: 20 | print("Error in importing modules ",e) 21 | 22 | class EllipseItem(QQuickPaintedItem): 23 | def __init__(self, parent = None): 24 | super(EllipseItem, self).__init__(parent) 25 | self.setFlag(QQuickItem.ItemHasContents, False) 26 | # print("What the fuck") 27 | 28 | # def paintEvent(self,e): 29 | # print('yolo') 30 | 31 | def paint(self, painter, opts): 32 | print("damn") 33 | painter.save() 34 | 35 | painter.setPen(Qt.red) 36 | painter.drawEllipse(opts.rect) 37 | 38 | painter.restore() 39 | -------------------------------------------------------------------------------- /tutOff2/__pycache__/EllipseItem.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hovo1990/pyQt5-QML-examples/7a0f39b2a7b6e9b9e3c16a01c4611782a1e4a01f/tutOff2/__pycache__/EllipseItem.cpython-34.pyc -------------------------------------------------------------------------------- /tutOff2/deployment.pri: -------------------------------------------------------------------------------- 1 | android-no-sdk { 2 | target.path = /data/user/qt 3 | export(target.path) 4 | INSTALLS += target 5 | } else:android { 6 | x86 { 7 | target.path = /libs/x86 8 | } else: armeabi-v7a { 9 | target.path = /libs/armeabi-v7a 10 | } else { 11 | target.path = /libs/armeabi 12 | } 13 | export(target.path) 14 | INSTALLS += target 15 | } else:unix { 16 | isEmpty(target.path) { 17 | qnx { 18 | target.path = /tmp/$${TARGET}/bin 19 | } else { 20 | target.path = /opt/$${TARGET}/bin 21 | } 22 | export(target.path) 23 | } 24 | INSTALLS += target 25 | } 26 | 27 | export(INSTALLS) 28 | -------------------------------------------------------------------------------- /tutOff2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /tutOff2/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | #!/usr/bin/env python 5 | # -*- coding: utf-8 -*- 6 | 7 | # -*- coding: utf-8 -*- 8 | ## -*- coding: utf-8 -*- 9 | ## -*- coding: utf-8 -*- 10 | #import sys 11 | #from PyQt5.QtCore import QObject, QUrl, Qt 12 | #from PyQt5.QtWidgets import QApplication 13 | #from PyQt5.QtQml import QQmlApplicationEngine 14 | 15 | ##THis fucking works mate 16 | 17 | 18 | 19 | import sys 20 | import os.path 21 | 22 | from PyQt5.QtCore import QObject, Qt 23 | from PyQt5.QtCore import QUrl 24 | from PyQt5.QtGui import QGuiApplication 25 | from PyQt5.QtQuick import QQuickView 26 | 27 | from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl 28 | from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine 29 | 30 | from EllipseItem import * 31 | 32 | #import myQML 33 | 34 | app = QGuiApplication(sys.argv) 35 | 36 | qmlRegisterType(EllipseItem, 'shapes', 1, 0, 'Ellipse') 37 | 38 | print('-----------------------------------------------------------------------') 39 | 40 | 41 | qmlFile = 'main.qml' 42 | 43 | #qmlFile = "qrc:data/" 44 | 45 | 46 | view = QQuickView() 47 | view.setResizeMode(QQuickView.SizeRootObjectToView) 48 | view.engine().quit.connect(app.quit) 49 | 50 | engine = view.engine() 51 | view.setSource(QUrl(qmlFile)) # putting at the end didn't solve referenceError 'This is supposed to solve all referenceErrors 52 | 53 | 54 | 55 | view.show() 56 | sys.exit(app.exec_()) 57 | 58 | 59 | -------------------------------------------------------------------------------- /tutOff2/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import shapes 1.0 3 | //import QtQuick.Window 2.1 4 | 5 | Rectangle { 6 | visible: true 7 | width: 360 8 | height: 360 9 | 10 | Ellipse { 11 | height:100 12 | width: 100 13 | anchors.fill: parent 14 | } 15 | 16 | MouseArea { 17 | anchors.fill: parent 18 | onClicked: { 19 | Qt.quit(); 20 | } 21 | } 22 | 23 | Text { 24 | text: qsTr("Hello World") 25 | font.pixelSize: 20 26 | anchors.centerIn: parent 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tutOff2/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutOff2/tutOff2.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | SOURCES += main.cpp 6 | 7 | RESOURCES += qml.qrc 8 | 9 | # Additional import path used to resolve QML modules in Qt Creator's code model 10 | QML_IMPORT_PATH = 11 | 12 | # Default rules for deployment. 13 | include(deployment.pri) 14 | 15 | DISTFILES += \ 16 | main.py \ 17 | EllipseItem.py 18 | -------------------------------------------------------------------------------- /tutOff2/tutOff2.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {a8c8ceca-ba1f-4cab-b29b-7b8cef94421b} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.4.0 GCC 64bit 62 | Desktop Qt 5.4.0 GCC 64bit 63 | qt.54.gcc_64_kit 64 | 0 65 | 0 66 | 0 67 | 68 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff2-Desktop_Qt_5_4_0_GCC_64bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | false 76 | true 77 | 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | -w 88 | -r 89 | 90 | false 91 | 92 | 93 | 94 | 2 95 | Build 96 | 97 | ProjectExplorer.BuildSteps.Build 98 | 99 | 100 | 101 | true 102 | Make 103 | 104 | Qt4ProjectManager.MakeStep 105 | 106 | -w 107 | -r 108 | 109 | true 110 | clean 111 | 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff2-Desktop_Qt_5_4_0_GCC_64bit-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | true 137 | 138 | false 139 | false 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | -w 148 | -r 149 | 150 | false 151 | 152 | 153 | 154 | 2 155 | Build 156 | 157 | ProjectExplorer.BuildSteps.Build 158 | 159 | 160 | 161 | true 162 | Make 163 | 164 | Qt4ProjectManager.MakeStep 165 | 166 | -w 167 | -r 168 | 169 | true 170 | clean 171 | 172 | 173 | 1 174 | Clean 175 | 176 | ProjectExplorer.BuildSteps.Clean 177 | 178 | 2 179 | false 180 | 181 | Release 182 | 183 | Qt4ProjectManager.Qt4BuildConfiguration 184 | 0 185 | true 186 | 187 | 2 188 | 189 | 190 | 0 191 | Deploy 192 | 193 | ProjectExplorer.BuildSteps.Deploy 194 | 195 | 1 196 | Deploy locally 197 | 198 | ProjectExplorer.DefaultDeployConfiguration 199 | 200 | 1 201 | 202 | 203 | 204 | false 205 | false 206 | false 207 | false 208 | true 209 | 0.01 210 | 10 211 | true 212 | 1 213 | 25 214 | 215 | 1 216 | true 217 | false 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | -1 238 | 239 | 240 | 241 | false 242 | %{buildDir} 243 | Custom Executable 244 | 245 | ProjectExplorer.CustomExecutableRunConfiguration 246 | 3768 247 | false 248 | true 249 | false 250 | false 251 | true 252 | 253 | 1 254 | 255 | 256 | 257 | ProjectExplorer.Project.TargetCount 258 | 1 259 | 260 | 261 | ProjectExplorer.Project.Updater.FileVersion 262 | 18 263 | 264 | 265 | Version 266 | 18 267 | 268 | 269 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/ItFuckingWorks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hovo1990/pyQt5-QML-examples/7a0f39b2a7b6e9b9e3c16a01c4611782a1e4a01f/tutOff2_InetVersion/ItFuckingWorks -------------------------------------------------------------------------------- /tutOff2_InetVersion/deployment.pri: -------------------------------------------------------------------------------- 1 | android-no-sdk { 2 | target.path = /data/user/qt 3 | export(target.path) 4 | INSTALLS += target 5 | } else:android { 6 | x86 { 7 | target.path = /libs/x86 8 | } else: armeabi-v7a { 9 | target.path = /libs/armeabi-v7a 10 | } else { 11 | target.path = /libs/armeabi 12 | } 13 | export(target.path) 14 | INSTALLS += target 15 | } else:unix { 16 | isEmpty(target.path) { 17 | qnx { 18 | target.path = /tmp/$${TARGET}/bin 19 | } else { 20 | target.path = /opt/$${TARGET}/bin 21 | } 22 | export(target.path) 23 | } 24 | INSTALLS += target 25 | } 26 | 27 | export(INSTALLS) 28 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | try: 4 | from PySide import QtCore 5 | from PySide import QtWidgets 6 | except: 7 | from PyQt5.QtCore import pyqtSlot as Slot 8 | from PyQt5 import QtCore 9 | from PyQt5 import QtWidgets 10 | 11 | try: 12 | from PyQt5.QtGui import QPainter 13 | from PyQt5.QtWidgets import QStyleOptionGraphicsItem 14 | from PyQt5.QtWidgets import QWidget 15 | from PyQt5.QtWidgets import QGraphicsItem 16 | 17 | from PyQt5.QtQuick import QQuickItem 18 | from PyQt5.QtQuick import QQuickPaintedItem 19 | except Exception as e: 20 | print("Error in importing modules ",e) 21 | 22 | class PaintedItem(QQuickPaintedItem): 23 | def __init__(self, parent = None): 24 | super(PaintedItem, self).__init__(parent) 25 | # self.setFlag(QQuickItem.ItemHasContents, False) 26 | # print("What the fuck") 27 | 28 | def paint(self, painter): 29 | painter.fillRect(self.contentsBoundingRect(), Qt.red); 30 | print("damn") 31 | # painter.save() 32 | 33 | # painter.setPen(Qt.red) 34 | # painter.drawEllipse(opts.rect) 35 | 36 | # painter.restore() 37 | 38 | 39 | 40 | 41 | import sys 42 | import os.path 43 | 44 | from PyQt5.QtCore import QObject, Qt 45 | from PyQt5.QtCore import QUrl 46 | from PyQt5.QtGui import QGuiApplication 47 | from PyQt5.QtQuick import QQuickView 48 | 49 | from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl 50 | from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine 51 | 52 | #from EllipseItem import * 53 | 54 | #import myQML 55 | 56 | app = QGuiApplication(sys.argv) 57 | 58 | qmlRegisterType(PaintedItem, 'mymodule', 1, 0, 'PaintedItem') 59 | 60 | print('-----------------------------------------------------------------------') 61 | 62 | 63 | qmlFile = 'main.qml' 64 | 65 | #qmlFile = "qrc:data/" 66 | 67 | 68 | view = QQuickView() 69 | view.setResizeMode(QQuickView.SizeRootObjectToView) 70 | view.engine().quit.connect(app.quit) 71 | 72 | engine = view.engine() 73 | view.setSource(QUrl(qmlFile)) # putting at the end didn't solve referenceError 'This is supposed to solve all referenceErrors 74 | 75 | 76 | 77 | view.show() 78 | sys.exit(app.exec_()) 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import mymodule 1.0 3 | 4 | Rectangle { 5 | color: "black" 6 | width: 500 7 | height: 500 8 | 9 | PaintedItem { 10 | x: 100 11 | y: 100 12 | //anchors.centerIn: parent 13 | width: 100 14 | height: 100 15 | 16 | MouseArea { 17 | anchors.fill: parent 18 | onClicked: { 19 | Qt.quit(); 20 | } 21 | } 22 | } 23 | 24 | PaintedItem { 25 | x: 300 26 | y: 300 27 | // anchors.centerIn: parent 28 | width: 100 29 | height: 100 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/tutOff2_InetVersion.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | SOURCES += main.cpp 6 | 7 | RESOURCES += qml.qrc 8 | 9 | # Additional import path used to resolve QML modules in Qt Creator's code model 10 | QML_IMPORT_PATH = 11 | 12 | # Default rules for deployment. 13 | include(deployment.pri) 14 | 15 | DISTFILES += \ 16 | main.py 17 | -------------------------------------------------------------------------------- /tutOff2_InetVersion/tutOff2_InetVersion.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {a8c8ceca-ba1f-4cab-b29b-7b8cef94421b} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.4.0 GCC 64bit 62 | Desktop Qt 5.4.0 GCC 64bit 63 | qt.54.gcc_64_kit 64 | 0 65 | 0 66 | 0 67 | 68 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff2_InetVersion-Desktop_Qt_5_4_0_GCC_64bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | false 76 | true 77 | 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | -w 88 | -r 89 | 90 | false 91 | 92 | 93 | 94 | 2 95 | Build 96 | 97 | ProjectExplorer.BuildSteps.Build 98 | 99 | 100 | 101 | true 102 | Make 103 | 104 | Qt4ProjectManager.MakeStep 105 | 106 | -w 107 | -r 108 | 109 | true 110 | clean 111 | 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff2_InetVersion-Desktop_Qt_5_4_0_GCC_64bit-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | true 137 | 138 | false 139 | false 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | -w 148 | -r 149 | 150 | false 151 | 152 | 153 | 154 | 2 155 | Build 156 | 157 | ProjectExplorer.BuildSteps.Build 158 | 159 | 160 | 161 | true 162 | Make 163 | 164 | Qt4ProjectManager.MakeStep 165 | 166 | -w 167 | -r 168 | 169 | true 170 | clean 171 | 172 | 173 | 1 174 | Clean 175 | 176 | ProjectExplorer.BuildSteps.Clean 177 | 178 | 2 179 | false 180 | 181 | Release 182 | 183 | Qt4ProjectManager.Qt4BuildConfiguration 184 | 0 185 | true 186 | 187 | 2 188 | 189 | 190 | 0 191 | Deploy 192 | 193 | ProjectExplorer.BuildSteps.Deploy 194 | 195 | 1 196 | Deploy locally 197 | 198 | ProjectExplorer.DefaultDeployConfiguration 199 | 200 | 1 201 | 202 | 203 | 204 | false 205 | false 206 | false 207 | false 208 | true 209 | 0.01 210 | 10 211 | true 212 | 1 213 | 25 214 | 215 | 1 216 | true 217 | false 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | -1 238 | 239 | 240 | 241 | false 242 | %{buildDir} 243 | Custom Executable 244 | 245 | ProjectExplorer.CustomExecutableRunConfiguration 246 | 3768 247 | false 248 | true 249 | false 250 | false 251 | true 252 | 253 | 1 254 | 255 | 256 | 257 | ProjectExplorer.Project.TargetCount 258 | 1 259 | 260 | 261 | ProjectExplorer.Project.Updater.FileVersion 262 | 18 263 | 264 | 265 | Version 266 | 18 267 | 268 | 269 | -------------------------------------------------------------------------------- /tutOff3_property/THisWorksTooYeah!!!!!!!: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hovo1990/pyQt5-QML-examples/7a0f39b2a7b6e9b9e3c16a01c4611782a1e4a01f/tutOff3_property/THisWorksTooYeah!!!!!!! -------------------------------------------------------------------------------- /tutOff3_property/deployment.pri: -------------------------------------------------------------------------------- 1 | android-no-sdk { 2 | target.path = /data/user/qt 3 | export(target.path) 4 | INSTALLS += target 5 | } else:android { 6 | x86 { 7 | target.path = /libs/x86 8 | } else: armeabi-v7a { 9 | target.path = /libs/armeabi-v7a 10 | } else { 11 | target.path = /libs/armeabi 12 | } 13 | export(target.path) 14 | INSTALLS += target 15 | } else:unix { 16 | isEmpty(target.path) { 17 | qnx { 18 | target.path = /tmp/$${TARGET}/bin 19 | } else { 20 | target.path = /opt/$${TARGET}/bin 21 | } 22 | export(target.path) 23 | } 24 | INSTALLS += target 25 | } 26 | 27 | export(INSTALLS) 28 | -------------------------------------------------------------------------------- /tutOff3_property/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /tutOff3_property/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # -*- coding: utf-8 -*- 5 | 6 | try: 7 | from PySide import QtCore 8 | from PySide import QtWidgets 9 | except: 10 | from PyQt5.QtCore import pyqtSlot as Slot 11 | from PyQt5 import QtCore 12 | from PyQt5 import QtWidgets 13 | 14 | try: 15 | from PyQt5.QtCore import (pyqtProperty, pyqtSignal, Q_CLASSINFO, QCoreApplication, QDate, QObject, QTime, QUrl) 16 | from PyQt5.QtGui import QPainter 17 | from PyQt5.QtWidgets import QStyleOptionGraphicsItem 18 | from PyQt5.QtWidgets import QWidget 19 | from PyQt5.QtWidgets import QGraphicsItem 20 | 21 | from PyQt5.QtQuick import QQuickItem 22 | from PyQt5.QtQuick import QQuickPaintedItem 23 | from PyQt5.QtCore import pyqtProperty 24 | except Exception as e: 25 | print("Error in importing modules ",e) 26 | 27 | 28 | 29 | 30 | class PaintedItem(QQuickPaintedItem): 31 | 32 | 33 | 34 | colorChanged = pyqtSignal() 35 | 36 | def __init__(self, parent = None): 37 | super(PaintedItem, self).__init__(parent) 38 | # self.setFlag(QQuickItem.ItemHasContents, False) 39 | # print("What the fuck") 40 | self._color = Qt.red 41 | 42 | # @pyqtProperty("QColor", fget = color, fset = setColor, notify = colorChanged) 43 | def getColor(self): 44 | return self._color 45 | 46 | # @color.setter 47 | def setColor(self,color): 48 | if self._color != color: 49 | self._color = color 50 | self.colorChanged.emit() 51 | self.update() 52 | 53 | 54 | 55 | def paint(self, painter): 56 | painter.fillRect(self.contentsBoundingRect(), self._color); 57 | print("damn") 58 | 59 | #THis fucking works yeah !!!!!! 60 | color = pyqtProperty("QColor", fget=getColor, fset= setColor, notify=colorChanged) 61 | 62 | 63 | import sys 64 | import os.path 65 | 66 | from PyQt5.QtCore import QObject, Qt 67 | from PyQt5.QtCore import QUrl 68 | from PyQt5.QtGui import QGuiApplication 69 | from PyQt5.QtQuick import QQuickView 70 | 71 | from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl 72 | from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine 73 | 74 | #from EllipseItem import * 75 | 76 | #import myQML 77 | 78 | app = QGuiApplication(sys.argv) 79 | 80 | qmlRegisterType(PaintedItem, 'mymodule', 1, 0, 'PaintedItem') 81 | 82 | print('-----------------------------------------------------------------------') 83 | 84 | 85 | qmlFile = 'main.qml' 86 | 87 | #qmlFile = "qrc:data/" 88 | 89 | 90 | view = QQuickView() 91 | view.setResizeMode(QQuickView.SizeRootObjectToView) 92 | view.engine().quit.connect(app.quit) 93 | 94 | engine = view.engine() 95 | view.setSource(QUrl(qmlFile)) # putting at the end didn't solve referenceError 'This is supposed to solve all referenceErrors 96 | 97 | 98 | 99 | view.show() 100 | sys.exit(app.exec_()) 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /tutOff3_property/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import mymodule 1.0 3 | 4 | Rectangle { 5 | color: "black" 6 | width: 500 7 | height: 500 8 | 9 | 10 | PaintedItem { 11 | //property string myColor: "green" 12 | x: 100 13 | y: 100 14 | //anchors.centerIn: parent 15 | width: 100 16 | height: 100 17 | color: "blue" 18 | 19 | MouseArea { 20 | anchors.fill: parent 21 | onClicked: { 22 | // Qt.quit(); 23 | parent.color = 'red'; 24 | } 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tutOff3_property/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutOff3_property/tutOff3_property.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | SOURCES += main.cpp 6 | 7 | RESOURCES += qml.qrc 8 | 9 | # Additional import path used to resolve QML modules in Qt Creator's code model 10 | QML_IMPORT_PATH = 11 | 12 | # Default rules for deployment. 13 | include(deployment.pri) 14 | 15 | DISTFILES += \ 16 | main.py 17 | -------------------------------------------------------------------------------- /tutOff3_property/tutOff3_property.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {a8c8ceca-ba1f-4cab-b29b-7b8cef94421b} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.4.0 GCC 64bit 62 | Desktop Qt 5.4.0 GCC 64bit 63 | qt.54.gcc_64_kit 64 | 0 65 | 0 66 | 0 67 | 68 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff3_property-Desktop_Qt_5_4_0_GCC_64bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | false 76 | true 77 | 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | -w 88 | -r 89 | 90 | false 91 | 92 | 93 | 94 | 2 95 | Build 96 | 97 | ProjectExplorer.BuildSteps.Build 98 | 99 | 100 | 101 | true 102 | Make 103 | 104 | Qt4ProjectManager.MakeStep 105 | 106 | -w 107 | -r 108 | 109 | true 110 | clean 111 | 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff3_property-Desktop_Qt_5_4_0_GCC_64bit-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | true 137 | 138 | false 139 | false 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | -w 148 | -r 149 | 150 | false 151 | 152 | 153 | 154 | 2 155 | Build 156 | 157 | ProjectExplorer.BuildSteps.Build 158 | 159 | 160 | 161 | true 162 | Make 163 | 164 | Qt4ProjectManager.MakeStep 165 | 166 | -w 167 | -r 168 | 169 | true 170 | clean 171 | 172 | 173 | 1 174 | Clean 175 | 176 | ProjectExplorer.BuildSteps.Clean 177 | 178 | 2 179 | false 180 | 181 | Release 182 | 183 | Qt4ProjectManager.Qt4BuildConfiguration 184 | 0 185 | true 186 | 187 | 2 188 | 189 | 190 | 0 191 | Deploy 192 | 193 | ProjectExplorer.BuildSteps.Deploy 194 | 195 | 1 196 | Deploy locally 197 | 198 | ProjectExplorer.DefaultDeployConfiguration 199 | 200 | 1 201 | 202 | 203 | 204 | false 205 | false 206 | false 207 | false 208 | true 209 | 0.01 210 | 10 211 | true 212 | 1 213 | 25 214 | 215 | 1 216 | true 217 | false 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | -1 238 | 239 | 240 | 241 | false 242 | %{buildDir} 243 | Custom Executable 244 | 245 | ProjectExplorer.CustomExecutableRunConfiguration 246 | 3768 247 | false 248 | true 249 | false 250 | false 251 | true 252 | 253 | 1 254 | 255 | 256 | 257 | ProjectExplorer.Project.TargetCount 258 | 1 259 | 260 | 261 | ProjectExplorer.Project.Updater.FileVersion 262 | 18 263 | 264 | 265 | Version 266 | 18 267 | 268 | 269 | -------------------------------------------------------------------------------- /tutOff4_signals/deployment.pri: -------------------------------------------------------------------------------- 1 | android-no-sdk { 2 | target.path = /data/user/qt 3 | export(target.path) 4 | INSTALLS += target 5 | } else:android { 6 | x86 { 7 | target.path = /libs/x86 8 | } else: armeabi-v7a { 9 | target.path = /libs/armeabi-v7a 10 | } else { 11 | target.path = /libs/armeabi 12 | } 13 | export(target.path) 14 | INSTALLS += target 15 | } else:unix { 16 | isEmpty(target.path) { 17 | qnx { 18 | target.path = /tmp/$${TARGET}/bin 19 | } else { 20 | target.path = /opt/$${TARGET}/bin 21 | } 22 | export(target.path) 23 | } 24 | INSTALLS += target 25 | } 26 | 27 | export(INSTALLS) 28 | -------------------------------------------------------------------------------- /tutOff4_signals/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QGuiApplication app(argc, argv); 7 | 8 | QQmlApplicationEngine engine; 9 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /tutOff4_signals/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | #!/usr/bin/env python 5 | # -*- coding: utf-8 -*- 6 | 7 | # -*- coding: utf-8 -*- 8 | 9 | try: 10 | from PySide import QtCore 11 | from PySide import QtWidgets 12 | except: 13 | from PyQt5.QtCore import pyqtSlot as Slot 14 | from PyQt5 import QtCore 15 | from PyQt5 import QtWidgets 16 | 17 | try: 18 | from PyQt5.QtQuick import QQuickPaintedItem 19 | from PyQt5.QtCore import (pyqtProperty, pyqtSignal, Q_CLASSINFO, QCoreApplication, QDate, QObject, QTime, QUrl) 20 | from PyQt5.QtCore import QTimerEvent 21 | from PyQt5.QtCore import QTimer 22 | 23 | from PyQt5.QtCore import qDebug 24 | from PyQt5.QtGui import QPainter 25 | from PyQt5.QtWidgets import QStyleOptionGraphicsItem 26 | from PyQt5.QtWidgets import QWidget 27 | from PyQt5.QtWidgets import QGraphicsItem 28 | 29 | from PyQt5.QtQuick import QQuickItem 30 | from PyQt5.QtCore import pyqtProperty 31 | except Exception as e: 32 | print("Error in importing modules ",e) 33 | 34 | 35 | 36 | 37 | class PaintedItem(QQuickPaintedItem): 38 | 39 | 40 | 41 | colorChanged = pyqtSignal() 42 | readyChanged = pyqtSignal(int) 43 | readySignal = pyqtSignal() 44 | #timerEvent 45 | 46 | def __init__(self, parent = None): 47 | super(PaintedItem, self).__init__(parent) 48 | # self.setFlag(QQuickItem.ItemHasContents, False) 49 | # print("What the fuck") 50 | self._color = Qt.red 51 | 52 | # timer = QTimer(self) 53 | # timer.timeout.connect(self.update) 54 | # timer.start(100) 55 | self.ready = 0 56 | self.startTimer(100) 57 | 58 | 59 | def timerEvent(self, timer): 60 | if self.ready >= 100: 61 | self.killTimer(timer.timerId()) 62 | # qDebug(self.readySignal)<<"readySignal" 63 | print("Ready Signal called") 64 | self.readySignal.emit() 65 | else: 66 | self.ready += 1 67 | print('yo ',self.ready) 68 | # qDebug(self.readyChanged) 69 | self.readyChanged.emit(self.ready) 70 | 71 | def getReadyNumber(self): 72 | return self.ready 73 | 74 | # @pyqtProperty("QColor", fget = color, fset = setColor, notify = colorChanged) 75 | def getColor(self): 76 | return self._color 77 | 78 | # @color.setter 79 | def setColor(self,color): 80 | if self._color != color: 81 | self._color = color 82 | self.colorChanged.emit() 83 | self.update() 84 | 85 | 86 | 87 | def paint(self, painter): 88 | painter.fillRect(self.contentsBoundingRect(), self._color); 89 | print("damn") 90 | 91 | #THis fucking works yeah !!!!!! 92 | color = pyqtProperty("QColor", fget=getColor, fset= setColor, notify=colorChanged) 93 | value = pyqtProperty(int, fget=getReadyNumber, notify=readyChanged) 94 | 95 | 96 | 97 | import sys 98 | import os.path 99 | 100 | from PyQt5.QtCore import QObject, Qt 101 | from PyQt5.QtCore import QUrl 102 | from PyQt5.QtGui import QGuiApplication 103 | from PyQt5.QtQuick import QQuickView 104 | 105 | from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl 106 | from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine 107 | 108 | #from EllipseItem import * 109 | 110 | #import myQML 111 | 112 | app = QGuiApplication(sys.argv) 113 | 114 | qmlRegisterType(PaintedItem, 'mymodule', 1, 0, 'PaintedItem') 115 | 116 | print('-----------------------------------------------------------------------') 117 | 118 | 119 | qmlFile = 'main.qml' 120 | 121 | #qmlFile = "qrc:data/" 122 | 123 | 124 | view = QQuickView() 125 | view.setResizeMode(QQuickView.SizeRootObjectToView) 126 | view.engine().quit.connect(app.quit) 127 | 128 | engine = view.engine() 129 | view.setSource(QUrl(qmlFile)) # putting at the end didn't solve referenceError 'This is supposed to solve all referenceErrors 130 | 131 | 132 | 133 | view.show() 134 | sys.exit(app.exec_()) 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /tutOff4_signals/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import mymodule 1.0 3 | 4 | Rectangle { 5 | // color: "black" 6 | width: 500 7 | height: 500 8 | 9 | Column 10 | { 11 | 12 | PaintedItem { 13 | id: myPaintedItem 14 | //property string myColor: "green" 15 | x: 100 16 | y: 100 17 | //anchors.centerIn: parent 18 | width: 100 19 | height: 100 20 | color: "green" 21 | 22 | onReadySignal: { 23 | color = "blue" 24 | } 25 | 26 | onReadyChanged: { 27 | readyStatus.text = value; 28 | } 29 | 30 | MouseArea { 31 | anchors.fill: parent 32 | onClicked: { 33 | // Qt.quit(); 34 | parent.color = 'red'; 35 | } 36 | } 37 | } 38 | 39 | Text { 40 | id: readyStatus 41 | text: "Hello world" 42 | font.pixelSize: 32 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tutOff4_signals/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutOff4_signals/tutOff4_signals.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | 5 | SOURCES += main.cpp 6 | 7 | RESOURCES += qml.qrc 8 | 9 | # Additional import path used to resolve QML modules in Qt Creator's code model 10 | QML_IMPORT_PATH = 11 | 12 | # Default rules for deployment. 13 | include(deployment.pri) 14 | 15 | DISTFILES += \ 16 | main.py 17 | -------------------------------------------------------------------------------- /tutOff4_signals/tutOff4_signals.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {a8c8ceca-ba1f-4cab-b29b-7b8cef94421b} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop Qt 5.4.0 GCC 64bit 62 | Desktop Qt 5.4.0 GCC 64bit 63 | qt.54.gcc_64_kit 64 | 0 65 | 0 66 | 0 67 | 68 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff4_signals-Desktop_Qt_5_4_0_GCC_64bit-Debug 69 | 70 | 71 | true 72 | qmake 73 | 74 | QtProjectManager.QMakeBuildStep 75 | false 76 | true 77 | 78 | false 79 | false 80 | 81 | 82 | true 83 | Make 84 | 85 | Qt4ProjectManager.MakeStep 86 | 87 | -w 88 | -r 89 | 90 | false 91 | 92 | 93 | 94 | 2 95 | Build 96 | 97 | ProjectExplorer.BuildSteps.Build 98 | 99 | 100 | 101 | true 102 | Make 103 | 104 | Qt4ProjectManager.MakeStep 105 | 106 | -w 107 | -r 108 | 109 | true 110 | clean 111 | 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/john1990/Dropbox/GitHub/webinarTut/IntegrationC/build-tutOff4_signals-Desktop_Qt_5_4_0_GCC_64bit-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | true 137 | 138 | false 139 | false 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | -w 148 | -r 149 | 150 | false 151 | 152 | 153 | 154 | 2 155 | Build 156 | 157 | ProjectExplorer.BuildSteps.Build 158 | 159 | 160 | 161 | true 162 | Make 163 | 164 | Qt4ProjectManager.MakeStep 165 | 166 | -w 167 | -r 168 | 169 | true 170 | clean 171 | 172 | 173 | 1 174 | Clean 175 | 176 | ProjectExplorer.BuildSteps.Clean 177 | 178 | 2 179 | false 180 | 181 | Release 182 | 183 | Qt4ProjectManager.Qt4BuildConfiguration 184 | 0 185 | true 186 | 187 | 2 188 | 189 | 190 | 0 191 | Deploy 192 | 193 | ProjectExplorer.BuildSteps.Deploy 194 | 195 | 1 196 | Deploy locally 197 | 198 | ProjectExplorer.DefaultDeployConfiguration 199 | 200 | 1 201 | 202 | 203 | 204 | false 205 | false 206 | false 207 | false 208 | true 209 | 0.01 210 | 10 211 | true 212 | 1 213 | 25 214 | 215 | 1 216 | true 217 | false 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | -1 238 | 239 | 240 | 241 | false 242 | %{buildDir} 243 | Custom Executable 244 | 245 | ProjectExplorer.CustomExecutableRunConfiguration 246 | 3768 247 | false 248 | true 249 | false 250 | false 251 | true 252 | 253 | 1 254 | 255 | 256 | 257 | ProjectExplorer.Project.TargetCount 258 | 1 259 | 260 | 261 | ProjectExplorer.Project.Updater.FileVersion 262 | 18 263 | 264 | 265 | Version 266 | 18 267 | 268 | 269 | --------------------------------------------------------------------------------