Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Switch case in Qt
Forum Updated to NodeBB v4.3 + New Features

Switch case in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 547 Views 2 Watching
  • 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.
  • D Offline
    D Offline
    dan1973
    wrote on last edited by
    #1

    the Swtich case x ... y is not working in Qt.

    it gives missing ; error.

    How to use multiple sequential Cases for ex: case 1 ... 100

    jsulmJ JonBJ Pl45m4P 3 Replies Last reply
    0
    • D dan1973

      the Swtich case x ... y is not working in Qt.

      it gives missing ; error.

      How to use multiple sequential Cases for ex: case 1 ... 100

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @dan1973 Can you please be more specific?
      What code did you write?
      Qt is not a programming language, so there is no "switch case in Qt".

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • D dan1973

        the Swtich case x ... y is not working in Qt.

        it gives missing ; error.

        How to use multiple sequential Cases for ex: case 1 ... 100

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @dan1973 said in Switch case in Qt:

        How to use multiple sequential Cases for ex: case 1 ... 100

        And further to @jsulm C++ does not support this (e.g. "ranges") in a switch...case anyway. C++ is not, say, Python with a match statement. For a range in C++ you'll want to write something like if (x >= 1 && x <= 100) rather than a switch-case.

        P.S.

        it gives missing ; error.

        Then your C++ code is incorrect, nothing to do with Qt.

        1 Reply Last reply
        3
        • D dan1973

          the Swtich case x ... y is not working in Qt.

          it gives missing ; error.

          How to use multiple sequential Cases for ex: case 1 ... 100

          Pl45m4P Online
          Pl45m4P Online
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @dan1973 said in Switch case in Qt:

          How to use multiple sequential Cases for ex: case 1 ... 100

          Good luck with writing a separate case for every number :))
          (No, don't try that. For your use-case there are other options in C++. You may consider even a simple if - statement)

          As previously being said, there is no such switch-case in C++.

          See here for further info.

          Type

          condition can only yield the following types:

          • integral types

          • enumeration types

          • class types

          If the yielded value is of a class type, it is contextually implicitly converted to an integral or enumeration type.
          If the (possibly converted) type is subject to integral promotions , the yielded value is converted to the promoted type.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1

          • Login

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