PyANGGui.GAnyObjectChooser¶
- class GAnyObjectChooser¶
A widget to select one or many object/s from a particular type.
Details
The selector widget allows the application to ask either for one object (
eOneObjectoreOneObjectList) or for many (eManyObjects) from a particular type.If you ask for one object, use the
getObjectcall to get the selected object (if any, can be NULL). If you ask for many, use the GAnyObjectChooser::getObjects call (if any, the list can be empty).Example:
GAnyObjectChooser widget( gui ); GKCentroidConfiguration *centroids = nullptr; widget.setType( gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject ); widget.show(); ... centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() ); if( centroids ){ ... do something with the selected object ... }
It is possible to set a filter to control which objects will be added. In the next example only objects with ID lower than the filterData will be considered:
bool myFilter( GKObject * object, void * filterData ) { return object->getId() < (int)(filterData); }
And, to use the filter:
GAnyObjectChooser widget( gui ); GKCentroidConfiguration *centroids = nullptr; widget.setFilter( myFilter, (void *)10 ); widget.setType( gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject ); ... centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() ); if( centroids ){ ... do something with the selected object ... }
Synopsis¶
Methods¶
def
__init__()def
clear()def
getObject()def
getType()def
getTypeLabel()def
insertWidget()def
isEmpty()def
selectOneOf()def
setFilterText()def
setFlat()def
setManyTitle()def
setType()def
setTypeLabel()def
setTypes()
Signals¶
def
typeChanged()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class ChooserMode¶
Select one or many objects?
- clear()¶
Clears the selection
See
setConsidersEmptyAsNew.See also
Returns the available types.
Returns the selected object or None if none was selected.
- getSelectedObjects()¶
- Return type:
.std.vectorGKObject
Returns the list of selected objects or an empty list if none was selected.
Returns the type currently selected
- hideSelectionTools()¶
Returns true if there’s no available objects for the specified filter and type.
- selectOneOf(options, windowTitle)¶
- Parameters:
options – .QSetGKObject
windowTitle – str
- selectOneOrManyOf(options, windowTitle)¶
- Parameters:
options – .QSetGKObject
windowTitle – str
- setConsidersEmptyAsNew(value)¶
- Parameters:
value – bool
By default the None object is labelled as None. Pass true to label it as New
See also
- setFilterText(filterText)¶
- Parameters:
filterText – str
Additionally to
setFilter, a text filter can be set. Only objects whose Name/ID/ExtendedID matches this filter will be shown.- setFlat()¶
Removes the group box border and title
- setManyTitle(title)¶
- Parameters:
title – str
Title for the Many object selection box
- setOneObjectTitle(title)¶
- Parameters:
title – str
- setSelectedObjects(objects)¶
- Parameters:
objects – .list of const GKObject
Sets the list of selected objects (and not the list of _selectable_ objects !).
- setType(atype[, amode=GAnyObjectChooser.ChooserMode.eOneObject[, listSubTypes=true]])¶
- Parameters:
atype –
GKTypeamode –
ChooserModelistSubTypes – bool
Sets the model from where objects will be read and the type of the objects to consider. If only objects of the specified type want to be listed (and not the ones inheriting from it) the listSubTypes should be False.
- setTypeLabel(typeLabel)¶
- Parameters:
typeLabel – str
When selecting one object ww list the objects with label with the object’s type. Use this call to * change the label from, for example,
GKObjectto Originator.- setTypes(amodel, someTypes[, amode=GAnyObjectChooser.ChooserMode.eOneObject[, listSubTypes=true]])¶
- Parameters:
amodel –
GKModelsomeTypes – list of strings
amode –
ChooserModelistSubTypes – bool
Sets the model from where objects will be read and only some types will be considered. Parameter someTypes must contain the internal type names. If someTypes QStringList is empty, then all possible types available in the model will be considered. If only objects of the specified types want to be listed (and not the ones inheriting from it) the listSubTypesm should be False.
- typeChanged()¶