April 2018
Beginner
714 pages
18h 21m
English
Create a new class and call it QtPythonValue:
class QtPythonValue {
public:
QtPythonValue();
QtPythonValue(const QtPythonValue &other);
QtPythonValue& operator=(const QtPythonValue &other);
QtPythonValue(int val);
QtPythonValue(const QString &str);
~QtPythonValue();
int toInt() const;
QString toString() const;
bool isNone() const;
private:
QtPythonValue(PyObject *ptr);
void incRef();
void incRef(PyObject *val);
void decRef();
PyObject *m_value;
friend class QtPython;
};
Next, implement the constructors, the assignment operator, and the destructor, as follows:
QtPythonValue::QtPythonValue() { incRef(Py_None); } QtPythonValue::QtPythonValue(const QtPythonValue &other) { incRef(other.m_value); ...Read now
Unlock full access