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. No actions in Qt, after I entered the Cin() data.
Forum Updated to NodeBB v4.3 + New Features

No actions in Qt, after I entered the Cin() data.

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 888 Views 1 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.
  • mgstanleyM Offline
    mgstanleyM Offline
    mgstanley
    wrote on last edited by
    #1
    #include <iostream>
     
    int main()
    {  
    //    An example that illustrates using the arithmetic operators:
        // define variables:
        unsigned int yards {}, feet {}, inches {};
        // Convert a distance in yards,feet and inches to inches
        std::cout << "Enter a distance as yards,feet and inches"
                  << " with the three values separated by spaces:"
                  << std::endl;
        std::cin >> yards >> feet >> inches;
        
    // define constants
        const unsigned feet_per_yard {3};
        const unsigned inches_per_feet {12};
    
     
        // define other formulations and elements
        unsigned total_inches {};
        total_inches = inches + inches_per_feet * (yards * feet_per_yard +feet);
        std::cout << "The distances corresponds to " << total_inches << " inches.\n";
    
     
        // Convert a distance in inches to yards feet and inches
        std::cout << "Rnter a distance in inches: ";
        std::cin >> total_inches;
    
     
        // define other formulations and elements
        feet = total_inches / inches_per_feet;
        inches = total_inches % inches_per_feet;
        yards = feet / feet_per_yard;
        feet = feet % feet_per_yard;
    
     
        std::cout << "The distance corresponds to"
                  << yards << " yards"
                  << feet << " feet"
                  << inches << " inches." << std::endl;
    }
    

    It runs well in Visual Studio.but not in Qt.
    after I entered the Cin() need data:1(space)2(space)3(enter key),then the cursor stopped when it moved to the second line...
    what is the wrong with this ?Thx.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @mgstanley Your code works fine for me when I build and run it with MinGW 7.3.0 in Qt Creator.

      How are you configuring your project? If you use qmake, make sure you have CONFIG += console in your .pro file.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      mgstanleyM 1 Reply Last reply
      1
      • JKSHJ JKSH

        @mgstanley Your code works fine for me when I build and run it with MinGW 7.3.0 in Qt Creator.

        How are you configuring your project? If you use qmake, make sure you have CONFIG += console in your .pro file.

        mgstanleyM Offline
        mgstanleyM Offline
        mgstanley
        wrote on last edited by
        #3

        @JKSH Thx,but where can find the .pro file?

        jsulmJ 1 Reply Last reply
        0
        • mgstanleyM mgstanley

          @JKSH Thx,but where can find the .pro file?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mgstanley said in No actions in Qt, after I entered the Cin() data.:

          but where can find the .pro file?

          Inside your project folder

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

          mgstanleyM 1 Reply Last reply
          0
          • T Offline
            T Offline
            Thembalami Msimango
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • jsulmJ jsulm

              @mgstanley said in No actions in Qt, after I entered the Cin() data.:

              but where can find the .pro file?

              Inside your project folder

              mgstanleyM Offline
              mgstanleyM Offline
              mgstanley
              wrote on last edited by
              #6

              @jsulm Thx, but awkward situation is, I still cannot find *.pro file in all the newly built Qt console application project, except in Qt widgets application project.

              And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹

              JKSHJ 1 Reply Last reply
              0
              • mgstanleyM mgstanley

                @jsulm Thx, but awkward situation is, I still cannot find *.pro file in all the newly built Qt console application project, except in Qt widgets application project.

                And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by JKSH
                #7

                @mgstanley said in No actions in Qt, after I entered the Cin() data.:

                I still cannot find *.pro file in all the newly built Qt console application project

                What build system did you choose for your projects: qmake, or CMake, or qbs?

                .pro files are used by qmake only.

                And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹

                Well, a widgets project should not have a console...

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                mgstanleyM 1 Reply Last reply
                1
                • JKSHJ JKSH

                  @mgstanley said in No actions in Qt, after I entered the Cin() data.:

                  I still cannot find *.pro file in all the newly built Qt console application project

                  What build system did you choose for your projects: qmake, or CMake, or qbs?

                  .pro files are used by qmake only.

                  And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹

                  Well, a widgets project should not have a console...

                  mgstanleyM Offline
                  mgstanleyM Offline
                  mgstanley
                  wrote on last edited by
                  #8

                  @JKSH thx...
                  but after added CONFIG += console sentence in the *.pro file, the problem is still there: 1 2 3 (enter), then nothing happened...

                  jsulmJ 1 Reply Last reply
                  0
                  • mgstanleyM mgstanley

                    @JKSH thx...
                    but after added CONFIG += console sentence in the *.pro file, the problem is still there: 1 2 3 (enter), then nothing happened...

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @mgstanley And you did a complete rebuild of your app after changing pro file (delete build folder, run qmake, build)?

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

                    mgstanleyM 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @mgstanley And you did a complete rebuild of your app after changing pro file (delete build folder, run qmake, build)?

                      mgstanleyM Offline
                      mgstanleyM Offline
                      mgstanley
                      wrote on last edited by
                      #10

                      @jsulm there is no build folder! 😮
                      In the untitled project folder , I only can see: main.cpp; untitled.pro; untitled.pro.user ,thses 3 files.

                      jsulmJ 1 Reply Last reply
                      0
                      • mgstanleyM mgstanley

                        @jsulm there is no build folder! 😮
                        In the untitled project folder , I only can see: main.cpp; untitled.pro; untitled.pro.user ,thses 3 files.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @mgstanley You can see the build folder in project settings in QtCreator. Usually it is net to project folder (but not inside the project folder).

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

                        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