Results 1 to 5 of 5

Thread: error: invalid conversion from ‘int’ to ‘InitializationState

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    315
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: invalid conversion from ‘int’ to ‘InitializationState

    Or even easier: use QFlags.

    Qt Code:
    1. typedef enum InitializationState
    2. {
    3.  
    4. INIT_NO_ONE = 0x00,
    5. INIT_NO_TWO = 0x01,
    6. INIT_NO_THREE = 0x02,
    7. INIT_NO_FOUR = 0x04
    8. };
    9.  
    10. Q_DECLARE_FLAGS( InitializationStates, InitializationState );
    11. Q_DECLARE_OPERATORS_FOR_FLAGS( InitializationStates );
    12.  
    13. InitializationStates initState = INIT_NO_ONE; // NOTE: "InitializationStates", not "InitializationState"
    14.  
    15. initState |= INIT_NO_TWO;
    16.  
    17. if ( initState.testFlag( INIT_NO_TWO ) )
    18. {
    19. // INIT_NO_TWO is set.
    20. }
    To copy to clipboard, switch view to plain text mode 

    Then you can AND, OR, and test bits using the QFlags operators with no need to cast anything.
    Last edited by d_stranz; 17th May 2012 at 17:53.

  2. The following user says thank you to d_stranz for this useful post:

    olidem (18th May 2012)

Similar Threads

  1. Invalid conversion error while Storing into Combobox
    By owais_blore in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 16:08
  2. X Error: BadRequest (invalid request code or no such operation) 1
    By Luc4 in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 18th April 2011, 14:40
  3. Building static Qt. Error 126 invalid argument
    By kea_ in forum Installation and Deployment
    Replies: 2
    Last Post: 20th March 2011, 07:58
  4. error: invalid use of void expression
    By ChineseGeek in forum Qt Programming
    Replies: 17
    Last Post: 3rd October 2009, 08:59
  5. error:invalid use of member
    By quickNitin in forum General Programming
    Replies: 4
    Last Post: 19th June 2006, 15:21

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.