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. How can I read property values set in QtDesigner for a custom widget?
QtWS25 Last Chance

How can I read property values set in QtDesigner for a custom widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 746 Views
  • 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.
  • stewartS Offline
    stewartS Offline
    stewart
    wrote on last edited by
    #1

    I am trying to create a new custom widget that can be used from QtDesigner. My new widget has its own properties declared in the class header...

    Q_PROPERTY(QString nodeId READ nodeId WRITE setNodeId)
    

    I added the property to the domXml() string...

               ...
               "  <property name=\"nodeId\">\n"
               "   <string>ns=4;s=device.sensor.value</string>\n"
               "  </property>\n"
               ...
    

    I then created an application that uses the widget. I drag the widget onto the main window. I set the property values using the property editor in QtDesigner.

    I can see that when the widget is instantiated that the property values are not set to those I configured in QtDesigner. Therefore I suppose I have to read the values from the application UI XML document and set them by myself in the constructor. Is this correct? Can anyone explain how I can read these values in the constructor?

    1 Reply Last reply
    0
    • stewartS Offline
      stewartS Offline
      stewart
      wrote on last edited by
      #2

      I see in the Ui_MainWindow.h that my widget is instantiated and then the properties are set in the setupUi() method. I can now see my properties are being set with values configured in QtDesigner. This is good. No further help required. Thanks.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Glad you found out and thanks for sharing.

        Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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