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. [SOLVED]List of QWidgets * and knowing what is what
QtWS25 Last Chance

[SOLVED]List of QWidgets * and knowing what is what

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.7k 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.
  • J Offline
    J Offline
    Jake007
    wrote on last edited by
    #1

    Hi!

    I have a few code design problems.
    I Have a list (QList) of widgets (QWidget *), where I've stored all widgets ( QComboBox, QLinedEdit ...) that go on a dialog whenever is called. Adding and showing them on a layout it's not a problem. But I'm stuck when I try to get data out of it. In Qt Docs I haven't found any methods provided for storing data.

    Does Qt provide any way to do this, without packing another variable for class type and then switch-ing or if-ing through class types and then casting?

    Regards,
    Jake


    Code is poetry

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

      Use "metaObject()":http://doc.qt.digia.com/qt/qobject.html#metaObject

      LE: better tell us what are you trying to achieve and maybe someone will give a better idea.

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jake007
        wrote on last edited by
        #3

        Thanks!

        That's part of a problem solved :) .
        No I only have to get data inputed by user out.

        I'm trying to dynamically built forms based on XML data (done). That dialog is then shown when user double clicks on graphics item (done). When it closes it, data from widgets must processed.

        It stops when I have to get data out of QWidget.
        With metaObject() it's now easy to use a bunch of ifs, but if I add another widget, I need to fix code at few other places as well.


        Code is poetry

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          Look further trough "QMetaObject documentation":http://doc.qt.digia.com/qt/qmetaobject.html //see "invokeMethod":http://doc.qt.digia.com/qt/qmetaobject.html#invokeMethod

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jake007
            wrote on last edited by
            #5

            Thanks.

            This methods solved quite a lot of trouble :) .

            Marked as solved.

            Regards,
            Jake


            Code is poetry

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Also, widgets have properties, and one of these properties is marked the user property. That property will contain the value you need. You can find out and query the property you need using QMetaObject.

              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