Results 1 to 2 of 2

Thread: i have issues with qt enum how to return value from key and key from value

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2019
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Arrow i have issues with qt enum how to return value from key and key from value

    i have enum
    enum x{
    y=2,
    e=3,
    r=5,
    u=9


    };
    how to use in switch case
    or just getting the value from key
    and key from value

  2. #2
    Join Date
    Nov 2019
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: i have issues with qt enum how to return value from key and key from value

    As far as I unterstood your question:

    Qt Code:
    1. enum xxxx{
    2. y=2,
    3. e=3,
    4. r=5,
    5. u=9
    6. };
    7.  
    8. xxxx YY;
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. YY = xxxx::e;
    2.  
    3. switch (YY)
    4. {
    5. case xxxx::e:
    6. {
    7. // do something with e
    8. break;
    9. }
    10. case xxxx::r:
    11. {
    12. // do something with r
    13. break;
    14. }
    15. case xxxx::u:
    16. {
    17. // do something with u
    18. break;
    19. }
    20. case xxxx::y:
    21. {
    22. // do something with y
    23. break;
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    Regards

Similar Threads

  1. Replies: 5
    Last Post: 26th April 2016, 19:59
  2. How To return C++ Enum to QML?
    By rhuang in forum Qt Quick
    Replies: 1
    Last Post: 16th May 2013, 12:47
  3. Replies: 1
    Last Post: 2nd January 2013, 10:48
  4. QT enum array
    By angarali06 in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2011, 16:21
  5. How to use QVariant with enum?
    By FinderCheng in forum Qt Programming
    Replies: 1
    Last Post: 25th December 2010, 22:23

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.