Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML - property url question
QtWS25 Last Chance

QML - property url question

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 4.3k 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.
  • cmessineoC Offline
    cmessineoC Offline
    cmessineo
    wrote on last edited by
    #1

    I'm playing around with QML, below is a simple component

    @
    Rectangle {
    id: rectangle1
    property string imageOn: "some filepath"
    property string imageOff: "some filepath"
    property string textMessage: "Submit"

        BorderImage {
        id: border_image1
        visible: !mouse_area1.pressed
        anchors.fill: parent
        source: parent.imageOn
    }
    
    BorderImage {
        id: border_image2
        anchors.fill: parent
        visible: mouse_area1.pressed
        source: parent.imageOff
    }
    

    }
    @

    Using QT Creator, If I drag this component and put it on another QML file in designer view the designer will show all the properties fine. I'd like the imageOn and imageOff properties to be set in the Designer by having the user choose a file, not by typing in a long file path. Is there anyway to do this?

    Thanks

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Try with

      @
      property url imageOn: "some filepath"
      @

      Also as this is a separate component I think it's better to use

      @
      property alias imageOn: border_image1.source
      @

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • cmessineoC Offline
        cmessineoC Offline
        cmessineo
        wrote on last edited by
        #3

        Thanks for the reply, but in the designer I was still forced to enter a string using both methods.
        I was hoping it would show a file dialog.

        1 Reply Last reply
        0
        • cmessineoC Offline
          cmessineoC Offline
          cmessineo
          wrote on last edited by
          #4

          When I set a property in a qml file like property url image: "some filepath" when I go in the designer it doesn't create a file dialog for the property. How can I set a property for a component that asks the user to choose from a file via the file dialog?

          Maybe this is not possible yet, but the image component and the border image component has the user choose a file through a dialog box for the source.

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            Merged this topics because they are about the same question.
            Please don't double post, but add your procedings or extra questions in the same post.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • cmessineoC Offline
              cmessineoC Offline
              cmessineo
              wrote on last edited by
              #6

              Eddy you are a good moderator, but you have no answers for my question. :-)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #7

                I don't believe this is supported in the designer yet for user-defined components, as far as I know. You can always add a feature request for it.

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                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