![]() |
VR-Forces 4.0.4 Class Documentation
|
The DtUiElement class is the base for which all UI elements are defined. More...
The DtUiElement class is the base for which all UI elements are defined.
If you wish to create a new UI element, you must subclass this item and:
1) Register is i the uiElement factory: DtUiElement()::elementFactory()->registerType<MyNewUiElement>("my-ui-element");
2) Your new UI element will have to create some content. Override the createDataEntryElement() method for this:
QWidget* DtUiStringElement::createDataEntryElement(QWidget* parent) { myLineEdit = new QLineEdit(parent); myLineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
QObject::connect(myLineEdit, SIGNAL(textChanged(const QString&)), &mySignalHandler, SLOT(elementChanged()));
return myLineEdit; }
3) Add code to take information from the descriptor and place it into your element void DtUiStringElement::setFromParameters(DtReaderWriter* parentRw) { DtReaderWriterRegistryData* val = value(parentRw);
if (val) { DtRwString* str = dynamic_cast<DtRwString*>(val->readerWriter());
if (str) { myLineEdit->blockSignals(true); myLineEdit->setText(QString::fromLocal8Bit(str->c_str())); myLineEdit->blockSignals(false); } }
DtUiElement::setFromParameters(parentRw); }
4) Create code to update the parameter descriptor element when your element changes void DtUiStringElement::elementChanged() { if (myValue) { DtRwString* str = dynamic_cast<DtRwString*>(myValue->readerWriter());
if (str) { str = (const char)myLineEdit->text().toLocal8Bit(); } }
DtUiElement::elementChanged(); }
5) Implement a clone and copy constructor method to be able to duplicate your ui element This class is used for signalling events up/down the chain
| DtUiElementEvent::DtUiElementEvent | ( | DtUiElement * | owner = 0, |
| DtUiElementEventTypes | type = DtUiElementTypeUnknown |
||
| ) | [inline] |
| DtUiElementEvent::DtUiElementEvent | ( | const DtUiElementEvent & | orig | ) | [inline] |
| DtUiElementEvent& DtUiElementEvent::operator= | ( | const DtUiElementEvent & | rhs | ) | [inline] |
| DtUiElement* DtUiElementEvent::owner | ( | ) | const [inline] |
| DtUiElementEventTypes DtUiElementEvent::type | ( | ) | const [inline] |
| void DtUiElementEvent::setType | ( | DtUiElementEventTypes | t | ) | [inline] |
| void DtUiElementEvent::setValue | ( | const QVariant & | val | ) | [inline] |
| const QVariant& DtUiElementEvent::value | ( | ) | const [inline] |
DtUiElement* DtUiElementEvent::myOwner [protected] |
Referenced by operator=().
QVariant DtUiElementEvent::myValue [protected] |
Referenced by operator=().
DtUiElementEventTypes DtUiElementEvent::myType [protected] |
Referenced by operator=().