Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [SOLVED] Can I create a QStack of the same type as my enum type?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    st2000
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

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

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • S Offline
        S Offline
        st2000
        wrote on last edited by
        #3

        D'oh - need more coffee.

        That worked!

        -thanks

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved