[SOLVED] Can I create a QStack of the same type as my enum type?



  • Hi...

    I have a program which is working well. I created an enum type variable and am using that variable in a select/case statement. Now Qt and C++ are doing a great job at keeping me honest.

    But I wish to now use a QStack to hold the enum variable:
    @ QStack<enumQueryState> state_history_stack;@
    This so I can keep a history of my states. That is I though I could now push the current state onto the stack and pop off a state should I want to travel backwards through the states. Well I just can not get the following select/case statement line to compile:
    @ switch(state_history_stack.top);@

    error: "switch quantity not an integer"

    Is there a problem with Qt or C++? Is there something I don't understand with regards to the QStack?

    Remember, I said this program was working well. That is, these lines compile and execute just the way I would expect:
    @ enum enumQueryState
    {
    DEFAULT_CATEGORY,
    ALL_CATEGORY,
    };
    enumQueryState queryState;
    switch (queryState)@

    -thanks



  • You should use :
    @switch(state_history_stack.top());@
    but I think that some compiler don't like enum in switch.



  • D'oh - need more coffee.

    That worked!

    -thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.