One instance of this class acts as wrapper for several import public methods of classes, derived from QObject, which should be made available by the call-method in python.
More...
|
| WidgetWrapper (UiOrganizer *uiOrganizer) |
| constructor
|
|
| ~WidgetWrapper () |
| destructor
|
|
MethodDescriptionList | getMethodList (QObject *object) |
| returns a list of MethodDescription, which contains all wrapped methods of the given object and all its base classes.
|
|
ito::RetVal | call (QObject *object, int methodIndex, void **_a) |
| call method which calls a wrapped method of any class derived from QObject at runtime. This call is for exampled executed by UiOrganizer::callMethod.
|
|
QMetaProperty | fakeProperty (const QObject *baseObject, const QString &fakePropertyName, QObject **destinationObject) |
| Method is able to handle unexisting properties and map them to existing ones (compatibility to QtDesigner)
|
|
|
void | initMethodHash () |
| initializes the hash table containing information about all methods which should be wrapped.
|
|
MethodDescription | buildMethodDescription (QByteArray signature, QString retType, int methodIndex, bool &ok) |
| creates an instance of MethodDescription which contains all necessary information in order to call the corresponding method at runtime using the method
|
|
ito::RetVal | callObject (QObject *object, int methodIndex, void **_a) |
|
ito::RetVal | callListWidget (QListWidget *listWidget, int methodIndex, void **_a) |
|
ito::RetVal | callComboBox (QComboBox *comboBox, int methodIndex, void **_a) |
|
ito::RetVal | callTabWidget (QTabWidget *tabWidget, int methodIndex, void **_a) |
|
ito::RetVal | callTableView (QTableView *tableView, int methodIndex, void **_a) |
|
ito::RetVal | callSplitter (QSplitter *splitter, int methodIndex, void **_a) |
|
ito::RetVal | callStatusBar (QStatusBar *statusBar, int methodIndex, void **_a) |
|
ito::RetVal | callMainWindow (QMainWindow *mainWindow, int methodIndex, void **_a) |
|
ito::RetVal | callWidget (QWidget *widget, int methodIndex, void **_a) |
|
ito::RetVal | callTableWidget (QTableWidget *tableWidget, int methodIndex, void **_a) |
|
ito::RetVal | callToolBar (QToolBar *toolbar, int methodIndex, void **_a) |
|
ito::RetVal | callAction (QAction *action, int methodIndex, void **_a) |
|
ito::RetVal | callLayout (QLayout *layout, int methodIndex, void **_a) |
|
ito::RetVal | callFormLayout (QFormLayout *layout, int methodIndex, void **_a) |
|
ito::RetVal | callGridLayout (QGridLayout *layout, int methodIndex, void **_a) |
|
ito::RetVal | callBoxLayout (QBoxLayout *layout, int methodIndex, void **_a) |
|
One instance of this class acts as wrapper for several import public methods of classes, derived from QObject, which should be made available by the call-method in python.
Usually, the huge meta system, provided by QMetaObject, of Qt gives the possibility to call slots and changes properties of all classes, derived from QObject, at runtime. Other public methods of these classes however can not be accessed by this runtime-system. Since the python-bindings which are integrated in the python-class UiDialog and UiDialogMetaObject use the Qt-meta system in order to access properties and connect to signals or call slots, it is also desirable to access other public methods of Qt-based classes. Frameworks, like PythonQt or PyQt have an internal parsing system which automatically creates wrappers for all public methods; here the class WidgetWrapper is a manually created wrapper for the most important methods.
ito::RetVal ito::WidgetWrapper::call |
( |
QObject * | object, |
|
|
int | methodIndex, |
|
|
void ** | _a ) |
call method which calls a wrapped method of any class derived from QObject at runtime. This call is for exampled executed by UiOrganizer::callMethod.
This method uses the class-name of object and checks if there is an call-implementation for the given methodIndex. If so, the call is executed (see switch-case inside of the method). If the method index does not fit, the class name of the base class of object is iteratively checked until either an appropriate method call could be executed or no other base class is available.
Please adapt the switch case in order to check for wrapped methods of other classes. Use the void-array _a and a reinterpret_cast- operation for accessing the necessary parameters and write back the return value of the "real" call to the wrapped public method.
- Parameters
-
[in] | object | is the instance casted to its base class QObject, whose wrapped public method should be called |
[in] | methodIndex | is the ID of the wrapped method to call |
| [in/out] | _a is a void-array containing the value for the return value as first element and the content of all argument as following elements. (similar to qt_metacall) |
- Returns
- true if call could successfully be executed (only if call itself was successful), false if method could not be found
- See also
- UiOrganizer::callMethod
QMetaProperty ito::WidgetWrapper::fakeProperty |
( |
const QObject * | baseObject, |
|
|
const QString & | fakePropertyName, |
|
|
QObject ** | destinationObject ) |
Method is able to handle unexisting properties and map them to existing ones (compatibility to QtDesigner)
In QtDesigner, sometimes it is possible to change properties that are not directly extracted from the QMetaObject-system. However, QtDesigner adds some artificial sets of properties, especially for widgets derived from QTreeView and QTableView. Therefore, if methods UiOrganizer::writeProperties and UiOrganizer::readProperties fail to address the given property, they call this method. In the given property can be transformed into a new property of a new object, then this is returned, else an empty QMetaProperty is returned.
- Parameters
-
[in] | baseObject | is the original input object |
[in] | fakePropertyName | is the artificial property name |
[out] | destinationObject | will be filled with a pointer to the new object, the new property is valid for (or NULL) |
- Returns
- instance of QMetaProperty (valid, if fakePropertyName could be converted to another property and object)
- See also
- UiOrganizer::writeProperties, UiOrganizer::readProperties
void ito::WidgetWrapper::initMethodHash |
( |
| ) |
|
|
private |
initializes the hash table containing information about all methods which should be wrapped.
Every public method of a class derived from QObject can be made available for access by Python if some information about this method are contained in a corresponding instance of the class MethodDescription. A list of such instances is linked to its appropriate class and therefore stored in the hash table m_methodHash whose key is the Qt-internal name of the corresponding class. Classes which are derived from that class also have access to the recently wrapped methods.
If you want to register new wrapper methods for an Qt-based class with name "newClass", you should at first create a temporary variable of type MethodDescriptionList, which is nothing else but a QList<MethodDescription>. Then you can add elements to this list for example using the helper-method
- See also
- buildMethodDescription. This method returns a new value of class MethodDescription. Finally you add this list of MethodDescription to m_methodHash with the key "newClass".
All wrapped methods can finally be called by the method
- See also
- call, which needs the method's index and a pointer to the base class QObject*. You must also adapt the method call, in order to successfully finish the wrapping process.
-
buildMethodDescription, MethodDescription, MethodDescriptionList