@@ -1137,7 +1137,7 static PyObject *PythonQt_SIGNAL(PyObject * /*type*/, PyObject *args) | |||||
1137 | return NULL; |
|
1137 | return NULL; | |
1138 | } |
|
1138 | } | |
1139 | // we do not prepend 0,1 or 2, why should we? |
|
1139 | // we do not prepend 0,1 or 2, why should we? | |
1140 | return PyString_FromString(value); |
|
1140 | return PyString_FromString(QByteArray("2") + value); | |
1141 | } |
|
1141 | } | |
1142 |
|
1142 | |||
1143 | static PyObject *PythonQt_SLOT(PyObject * /*type*/, PyObject *args) |
|
1143 | static PyObject *PythonQt_SLOT(PyObject * /*type*/, PyObject *args) | |
@@ -1147,7 +1147,7 static PyObject *PythonQt_SLOT(PyObject * /*type*/, PyObject *args) | |||||
1147 | return NULL; |
|
1147 | return NULL; | |
1148 | } |
|
1148 | } | |
1149 | // we do not prepend 0,1 or 2, why should we? |
|
1149 | // we do not prepend 0,1 or 2, why should we? | |
1150 | return PyString_FromString(value); |
|
1150 | return PyString_FromString(QByteArray("1") + value); | |
1151 | } |
|
1151 | } | |
1152 |
|
1152 | |||
1153 | static PyMethodDef PythonQt_Qt_methods[] = { |
|
1153 | static PyMethodDef PythonQt_Qt_methods[] = { |
@@ -143,7 +143,6 | |||||
143 | - PythonQt is not as Pythonic as PyQt in many details (e.g. operator mapping, pickling, translation support, ...) and it is mainly thought for embedding and intercommunication between Qt/Cpp and Python |
|
143 | - PythonQt is not as Pythonic as PyQt in many details (e.g. operator mapping, pickling, translation support, ...) and it is mainly thought for embedding and intercommunication between Qt/Cpp and Python | |
144 | - PythonQt allows to communicate in both directions, e.g. calling a Python object from C++ AND calling a C++ method from Python, while PyQt only handles the Python->C++ direction |
|
144 | - PythonQt allows to communicate in both directions, e.g. calling a Python object from C++ AND calling a C++ method from Python, while PyQt only handles the Python->C++ direction | |
145 | - PythonQt offers properties as Python attributes, while PyQt offers them as setter/getter methods (e.g. QWidget.width is a property in PythonQt and a method in PyQt) |
|
145 | - PythonQt offers properties as Python attributes, while PyQt offers them as setter/getter methods (e.g. QWidget.width is a property in PythonQt and a method in PyQt) | |
146 | - PythonQt offer QtCore.SIGNAL() and QtCore.SLOT() methods for compability, but no 0/1/3 is prepended |
|
|||
147 | - PythonQt does not support instanceof checks for Qt classes, except for the exact match and derived Python classes |
|
146 | - PythonQt does not support instanceof checks for Qt classes, except for the exact match and derived Python classes | |
148 | - QObject.emit to emit Qt signals from Python is not yet implemented |
|
147 | - QObject.emit to emit Qt signals from Python is not yet implemented | |
149 | - PythonQt does not offer to add new signals to Python/C++ objects |
|
148 | - PythonQt does not offer to add new signals to Python/C++ objects |
@@ -46,8 +46,14 | |||||
46 |
|
46 | |||
47 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable) |
|
47 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable) | |
48 | { |
|
48 | { | |
49 |
QByteArray signalTmp |
|
49 | QByteArray signalTmp; | |
50 | signalTmp += signal; |
|
50 | char first = signal.at(0); | |
|
51 | if (first>='0' && first<='9') { | |||
|
52 | signalTmp = signal; | |||
|
53 | } else { | |||
|
54 | signalTmp = "2" + signal; | |||
|
55 | } | |||
|
56 | ||||
51 |
|
|
57 | if (sender) { | |
52 | return PythonQt::self()->addSignalHandler(sender, signalTmp, callable); |
|
58 | return PythonQt::self()->addSignalHandler(sender, signalTmp, callable); | |
53 | } else { |
|
59 | } else { | |
@@ -59,21 +65,35 bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, Q | |||||
59 | { |
|
65 | { | |
60 | bool r = false; |
|
66 | bool r = false; | |
61 | if (sender && receiver) { |
|
67 | if (sender && receiver) { | |
62 |
QByteArray signalTmp |
|
68 | QByteArray signalTmp; | |
63 | signalTmp += signal; |
|
69 | char first = signal.at(0); | |
64 | QByteArray slotTmp("1"); |
|
70 | if (first>='0' && first<='9') { | |
65 |
sl |
|
71 | signalTmp = signal; | |
66 | if (receiver) { |
|
72 | } else { | |
67 | r = QObject::connect(sender, signalTmp, receiver, slotTmp); |
|
73 | signalTmp = "2" + signal; | |
|
74 | } | |||
|
75 | ||||
|
76 | QByteArray slotTmp; | |||
|
77 | first = slot.at(0); | |||
|
78 | if (first>='0' && first<='9') { | |||
|
79 | slotTmp = slot; | |||
|
80 | } else { | |||
|
81 | slotTmp = "1" + slot; | |||
68 | } |
|
82 | } | |
|
83 | r = QObject::connect(sender, signalTmp, receiver, slotTmp); | |||
69 | } |
|
84 | } | |
70 | return r; |
|
85 | return r; | |
71 | } |
|
86 | } | |
72 |
|
87 | |||
73 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable) |
|
88 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable) | |
74 | { |
|
89 | { | |
75 |
QByteArray signalTmp |
|
90 | QByteArray signalTmp; | |
76 | signalTmp += signal; |
|
91 | char first = signal.at(0); | |
|
92 | if (first>='0' && first<='9') { | |||
|
93 | signalTmp = signal; | |||
|
94 | } else { | |||
|
95 | signalTmp = "2" + signal; | |||
|
96 | } | |||
77 | if (sender) { |
|
97 | if (sender) { | |
78 | return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable); |
|
98 | return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable); | |
79 | } else { |
|
99 | } else { | |
@@ -85,13 +105,23 bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal | |||||
85 | { |
|
105 | { | |
86 | bool r = false; |
|
106 | bool r = false; | |
87 | if (sender && receiver) { |
|
107 | if (sender && receiver) { | |
88 |
QByteArray signalTmp |
|
108 | QByteArray signalTmp; | |
89 | signalTmp += signal; |
|
109 | char first = signal.at(0); | |
90 | QByteArray slotTmp("1"); |
|
110 | if (first>='0' && first<='9') { | |
91 |
sl |
|
111 | signalTmp = signal; | |
92 | if (receiver) { |
|
112 | } else { | |
93 | r = QObject::disconnect(sender, signalTmp, receiver, slotTmp); |
|
113 | signalTmp = "2" + signal; | |
|
114 | } | |||
|
115 | ||||
|
116 | QByteArray slotTmp; | |||
|
117 | first = slot.at(0); | |||
|
118 | if (first>='0' && first<='9') { | |||
|
119 | slotTmp = slot; | |||
|
120 | } else { | |||
|
121 | slotTmp = "1" + slot; | |||
94 | } |
|
122 | } | |
|
123 | ||||
|
124 | r = QObject::disconnect(sender, signalTmp, receiver, slotTmp); | |||
95 | } |
|
125 | } | |
96 | return r; |
|
126 | return r; | |
97 | } |
|
127 | } |
General Comments 0
You need to be logged in to leave comments.
Login now