Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved property aus QtObject neu initialisieren (QML)

    German
    2
    8
    449
    Loading More Posts
    • 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.
    • G
      Galilio last edited by

      Hallo Zusammen,

      folgende Datei habe ich:

      QtObject {
      
          property QtObject darkBg: QtObject {
              readonly property color backgroundNormalColor:                   "green"
              readonly property color textNormalColor:                         "red"
              readonly property url   normalImage:                             ""
      		....
      
              readonly property color backgroundSelectedColor:                 "yellow"
              readonly property color textSelectedColor:                       ...
              readonly property url   selectedImage:                           ""
      
              readonly property int   width:                                   50
              readonly property int   normalHeight:                            45
              readonly property int   depressedHeight:                         48
      
              readonly property int   contentDisplay:                          contentDisplayType.textOnly
      
              readonly property font  font:                                    ...
          }
      	property QtObject lightBg: QtObject {
      		......
      	
      	}
      
          property QtObject blueBg: QtObject {
              readonly property color textGhostedColor:                        "green"
              readonly property color focusFrameGhostedColor:                  "blue"
      
          }
      	
          readonly property QtObject contentDisplayType: QtObject {
              property int textOnly       :  0 // Display the text only
              property int imageOnly      :  1 // Display the image only
              property int textAndImage   :  2 // Display the text and the image
          }
      }
      

      in diesen datei werde alle möglische Farben, was einen Button haben kann, definiert.
      meine Frage: Wie kann ich z.b auf den font oder normalHeight um einen neue Value zuzuweisen?

      Danke

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @Galilio last edited by

        @Galilio da alle properties readonly sind, würd ich mal sagen, nein, du kannst du bei laufenden Betrieb nicht ändern.

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        G 1 Reply Last reply Reply Quote 0
        • G
          Galilio @J.Hilk last edited by

          @J-Hilk
          danke für die Antwort.
          Wenn ich den readonly weglasse, wie greife ich den auf einzelne Property?

          folgende habe ich versucht: wenn die Buttons einen lightBg haben sollen, dann habe ich folgende gemacht:

          property QtObject buttonStyle: QQtButtonStyle.lightBg
          

          aber wenn ich z.b nur den normalHeight neue Value zuweisen möchte: Wie tue ich das?

          Danke

          1 Reply Last reply Reply Quote 0
          • G
            Galilio last edited by

            @J-Hilk
            Wie kann ich bitte auf diese Property zugreifen?

            Danke in voraus

            J.Hilk 1 Reply Last reply Reply Quote 0
            • J.Hilk
              J.Hilk Moderators @Galilio last edited by

              @Galilio tja, bin mir net sicher, ich nutze normalweise nicht die QML property QtObject Objekte, ich würde vermuten ganz normal:

              QQtButtonStyle.lightBg.normalHeight: 200

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

              Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              G 1 Reply Last reply Reply Quote 0
              • G
                Galilio @J.Hilk last edited by

                @J-Hilk
                wenn ich so mache, dann bekomme ich diese Fehlermeldung:

                Non-existent attached object 
                
                G 1 Reply Last reply Reply Quote 0
                • G
                  Galilio @Galilio last edited by

                  @J-Hilk

                  wenn ich so was habe:

                  property QtObject buttonStyle: QQtButtonStyle.lightBg
                  

                  dann versuche ich auf die Property in der QObject zugreifen (einfach auslesen) --> Das geht nicht Warum?

                  Ich bekomme die Fehlermeldung: Es sei:

                  Unable to assign [undefined] to QColor
                  

                  Das verstehe ich nicht!!!

                  G 1 Reply Last reply Reply Quote 0
                  • G
                    Galilio @Galilio last edited by

                    Um die Property neu zu initialisieren , müssen nicht readonly sein.
                    Zweiten man braucht einen Hilfsvariable von type QtObject um die Überschreibung zu ermöglischen.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post