Results 1 to 5 of 5

Thread: Switch case not casing

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Switch case not casing

    This one is quite bizzare, have anyone experience something like this before?

    Qt Code:
    1. GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent)
    2. {
    3. m_iSet = 1;
    4. }
    5.  
    6. void GLWidget::LoadGLTexture()
    7. {
    8. LoadAppropriateTextures(m_iSet);
    9. }
    10.  
    11. void GLWidget::LoadAppropriateTextures(int iTextureSet)
    12. {
    13. qDebug() << "textures set" << iTextureSet;
    14. switch(iTextureSet)
    15. {
    16. case 1:
    17. {
    18. qDebug() << "entered here - 1";
    19. }
    20. case 2:
    21. {
    22. qDebug() << "entered here - 2";
    23. }
    24. case 3:
    25. {
    26. qDebug() << "entered here - 3";
    27. }
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    This is the result I get:

    textures set 1
    entered here - 1
    entered here - 2
    entered here - 3

    Any ideas?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Switch case not casing

    You need a break!
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Switch case not casing

    Or even two
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Switch case not casing

    I'll admit, I needed a lot more than one or two breaks . Now for a real one.

  5. #5
    Join Date
    Nov 2012
    Posts
    48
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Switch case not casing

    you need breake in the end of each case
    Regards,

Similar Threads

  1. convert upper-case to lower-case
    By RENOLD in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2012, 07:30
  2. QKeyEvent - lower case vs upper case keys?
    By ArkKup in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2012, 15:58
  3. Switch case in Qvector object
    By rk0747 in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2010, 07:35
  4. Replies: 1
    Last Post: 3rd February 2010, 06:01
  5. How to debug with dbg in this case?
    By vql in forum Newbie
    Replies: 25
    Last Post: 2nd April 2007, 16:52

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.