Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. property aus QtObject neu initialisieren (QML)
Forum Updated to NodeBB v4.3 + New Features

property aus QtObject neu initialisieren (QML)

Scheduled Pinned Locked Moved Solved German
8 Posts 2 Posters 1.2k 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.
  • G Offline
    G Offline
    Galilio
    wrote on last edited by
    #1

    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.HilkJ 1 Reply Last reply
    0
    • G Galilio

      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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @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


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

      G 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

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

        G Offline
        G Offline
        Galilio
        wrote on last edited by
        #3

        @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
        0
        • G Offline
          G Offline
          Galilio
          wrote on last edited by
          #4

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

          Danke in voraus

          J.HilkJ 1 Reply Last reply
          0
          • G Galilio

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

            Danke in voraus

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @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


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

            G 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @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

              G Offline
              G Offline
              Galilio
              wrote on last edited by
              #6

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

              Non-existent attached object 
              
              G 1 Reply Last reply
              0
              • G Galilio

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

                Non-existent attached object 
                
                G Offline
                G Offline
                Galilio
                wrote on last edited by
                #7

                @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
                0
                • G Galilio

                  @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 Offline
                  G Offline
                  Galilio
                  wrote on last edited by
                  #8

                  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
                  0

                  • Login

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