Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtPropertyBrowser + processing valuechanged signal example

QtPropertyBrowser + processing valuechanged signal example

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    phamtv
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarekR22
      wrote on last edited by
      #2

      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()));
      }
      @

      1 Reply Last reply
      0
      • P Offline
        P Offline
        phamtv
        wrote on last edited by
        #3

        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!!!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved