Results 1 to 2 of 2

Thread: Swich Control - How to get True or false?

  1. #1
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Swich Control - How to get True or false?

    Hi,

    I want to get switch state like true or false, Am I doing this right?

    Code snippet:
    Qt Code:
    1. Switch {
    2. id: idswitch
    3. checked: false
    4. onCheckedChanged: {
    5. console.log("Switch");
    6. if (idswitch.state == "on")
    7. {
    8. console.log("toggle - True");
    9. }
    10.  
    11. if (idswitch.state === true)
    12. {
    13. console.log("toggle - True");
    14. }
    15.  
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 
    Anything else to add, like
    Qt Code:
    1. states: [
    2. State { name: "state1"; when: sharedCondition },
    3. State { name: "state2"; when: sharedCondition }
    4. ]
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 10th October 2016 at 13:15.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Swich Control - How to get True or false?

    So you are checking for a state name "on" but your states are called "state1" and "state2"?
    Did you set the state property somewhere and expect to be "on"?

    Cheers,
    _

    P.S.: [code] tags and sensible identation would be great

  3. The following user says thank you to anda_skoa for this useful post:

    Mathan (11th October 2016)

Similar Threads

  1. Replies: 1
    Last Post: 31st July 2014, 09:55
  2. Replies: 3
    Last Post: 29th July 2014, 19:18
  3. Qt true,false speed
    By mero in forum Qt Programming
    Replies: 3
    Last Post: 9th October 2010, 21:09
  4. Replies: 9
    Last Post: 22nd July 2010, 09:40
  5. Qt for S60, compiler warning regarding TRUE/FALSE
    By Archimedes in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd October 2009, 15:09

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.