QtPropertyBrowser + processing valuechanged signal example



  • Does anyone have an example that demonstrates how to process the value changed signal of the QtVariantPropertyManager for the QtPropertyBrowser control? Are you suppose to key off of the property name? Is there a way to assign a tag to the property for ease of processing?

    Thanks for your time and effort



  • You are asking about classes which are not in documentation: QtVariantPropertyManager, QtPropertyBrowser.
    In general to handle properties you have meta data: QMetaProperty.
    There is method: QMetaProperty::hasNotifySignal() to check if property has a notification signal.
    So it would be like this:

    @
    QObject* obj = yorPointerToObject();
    int propIndex = obj->metaObject()->indexOfProperty("proertyName");
    Q_ASSERT(propIndex>=0);
    QMetaProperty metaProp = obj->metaObject()->property(propIndex);
    if (metaProp.hasNotifySignal()) {
    connect(obj, metaProp.notifySignal().signature(), reciver, SLOT(SomeSlot()));
    }
    @



  • Thank you for your response. However, my application is dynamically populating the QtPropertyBrowser without the use of metaObjects. To give you more details, I am creating an application the communicates to a device via usb/serial communication. The properties that I am populating the QtPropertyBrowser with are the properties of the device. I´ve used the simple example that came along with the QtPropertyBrowser framework. Everything looks great except for the fact that I am not sure how to process the valucechanged signal. A snippet of the how I initially thought about handling the signal is as follow. Your response has lead me to believe though, that I might need a QMap of the property and an assigned index to process the value changed signal. However, what happens if there are 2 properties with the same name?

    @
    void onvalueChanged(QtProperty* sender, QVariant e)
    {
    QMessageBox box(QMessageBox::Information, "onvalueChanged",
    "onvalueChanged invoked!!", QMessageBox::Ok);
    box.exec();

    // Fault 1 Output
    if (sender->propertyName() == "Polarity"){}
    else if (sender->propertyName() == "Overvoltage"){}
    else if (sender->propertyName() == "Undervoltage"){}
    else if (sender->propertyName() == "Early Warning"){}
    else if (sender->propertyName() == "MON1"){}
    else if (sender->propertyName() == "MON2"){}
    else if (sender->propertyName() == "MON3"){}
    else if (sender->propertyName() == "MON4"){}
    else if (sender->propertyName() == "MON5"){}
    else if (sender->propertyName() == "MON6"){}
    else if (sender->propertyName() == "MON7"){}
    else if (sender->propertyName() == "MON8"){}
    else if (sender->propertyName() == "MON9"){}
    else if (sender->propertyName() == "MON10"){}
    else if (sender->propertyName() == "MON11"){}
    else if (sender->propertyName() == "MON12"){}
    
    // Fault 2 Output
    else if (sender->propertyName() == "Polarity"){}
    else if (sender->propertyName() == "Overvoltage"){}
    else if (sender->propertyName() == "Undervoltage"){}
    else if (sender->propertyName() == "Early Warning"){}
    else if (sender->propertyName() == "MON1"){}
    else if (sender->propertyName() == "MON2"){}
    else if (sender->propertyName() == "MON3"){}
    else if (sender->propertyName() == "MON4"){}
    else if (sender->propertyName() == "MON5"){}
    else if (sender->propertyName() == "MON6"){}
    else if (sender->propertyName() == "MON7"){}
    else if (sender->propertyName() == "MON8"){}
    else if (sender->propertyName() == "MON9"){}
    else if (sender->propertyName() == "MON10"){}
    else if (sender->propertyName() == "MON11"){}
    else if (sender->propertyName() == "MON12"){}
    

    }
    @

    thanks for your time and effort!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.