Results 1 to 11 of 11

Thread: Property alias - make visible rectangle in other qml file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Property alias - make visible rectangle in other qml file

    That makes no sense.

    ToChange.qml defines "callUrl" as an alias for "visible" of another element, which is a boolean property.
    You can't assign 'T' to a boolean.

    If ToClick needs to change the visible property of item1 inside ToChange, then just assign the value you need (true or false) to the alias property.
    You might want to use a different name then callUrl, since it is a boolean, not an url

    Cheers,
    _

  2. #2
    Join Date
    Aug 2016
    Posts
    36
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Property alias - make visible rectangle in other qml file

    Thanks for the explanation. Now I also want to change color of the rectangle of item1 in ToChange.qml on click of ToClick.qml. I tried but how to get it working?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Property alias - make visible rectangle in other qml file

    Assuming "item1" is your rectangle, just make an alias property for its "color" property.

    Cheers,
    _

  4. #4
    Join Date
    Aug 2016
    Posts
    36
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Property alias - make visible rectangle in other qml file

    No, item1 is the Item, in which a rectangle is placed called circle. So how do I change the color of this circle from clicking on a rectangle of the other file?

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Property alias - make visible rectangle in other qml file

    Give the rectange an id, create an alias property for the rectangle's color using that id.

    Cheers,
    _

  6. #6
    Join Date
    Aug 2016
    Posts
    36
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Property alias - make visible rectangle in other qml file

    This is what I have, but it is not changing color of the rectangle called circle:

    ToClick.qml:
    Qt Code:
    1. onClicked:
    2. {
    3. luncherList.colorRef = "blue";
    4. }
    To copy to clipboard, switch view to plain text mode 

    ToChange.qml:
    Qt Code:
    1. property alias colorRef: circle.colorUrl
    2.  
    3. Rectangle {
    4. id: circle
    5. property color colorUrl
    6. onColorUrlChanged:
    7. {
    8. console.log("hello3");
    9. circle.colorUrl = "blue"
    10. }
    To copy to clipboard, switch view to plain text mode 

    Can you tell me what I am doing wrong?

Similar Threads

  1. Replies: 1
    Last Post: 24th June 2016, 04:32
  2. QgraphicsView rubber band selection rectangle not visible
    By tarunrajsingh in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2013, 16:44
  3. Replies: 2
    Last Post: 22nd December 2010, 14:58
  4. Make Grid of Rectangle
    By sagirahmed in forum Newbie
    Replies: 1
    Last Post: 8th October 2010, 06:59
  5. qresource file alias problem with svg
    By giotto in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2008, 15:59

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.