Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7569445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:10:03+00:00 2026-05-30T15:10:03+00:00

I’m somewhat new to C++ and QT. Trying to run a very simple program

  • 0

I’m somewhat new to C++ and QT.
Trying to run a very simple program in QtCreator, which uses console input on WinXP:

#include <QString>
#include <QTextStream>

int main() {
    QTextStream streamOut(stdout);
    QTextStream streamIn(stdin);
    QString s1("This "), s2("is a "), s3("string.");
    QString s4 = s1 + s2 + s3;
    streamOut << s4 << endl;
    streamOut << "The length of that string is " << s4.length() << endl;
    streamOut << "Enter a sentence with whitespaces: " << endl;
    s4 = streamIn.readLine();
    streamOut << "Here is your sentence: \n" << s4 << endl;
    streamOut << "The length of your sentence is: " << s4.length() << endl;
    return 0;
}

Problem is that native QTCreator’s application output, for it’s name, doesn’t support typing in things. Here is application output:

Starting C:\QProject\test-build-desktop-Qt_4_8_0_for_Desktop_-MinGW_Qt_SDK___>z>>\debug\test.exe…

This is a string.

The length of that string is 17

Enter a sentence with whitespaces:

Qml debugging is enabled. Only use this in a safe environment!

I’ve tried checking “Run in terminal” in Projects>Desktop>Run as some answers to similar questions here suggested and the terminal shows up, but it doesn’t seem to interact with the program anyhow. Terminal’s output:

Press RETURN to close this window…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:10:04+00:00Added an answer on May 30, 2026 at 3:10 pm

    I would say that checking Run in terminal is correct and needed.

    What is surprising is that you don’t get any compile error, as there is a mistake at line 8 :

    cout << "Enter a sentence: "<<;
    

    The last << is wrong.

    Correcting your code, I get this :

    #include <QString>
    #include <QTextStream>
    QTextStream cout(stdout);
    QTextStream cin(stdin);
    
    int main() {
        QString s2;
        cout << "Enter a sentence: ";
        s2 = cin.readLine();
        cout << "Here is your sentence:" << s2 << endl;
        cout << "The length of your sentence is: " << s2.length() << endl;
        return 0;
    }
    

    which works fine on my computer (WinXP, QtCreator 2.2.0).

    Are you sure your Qt project is correct and that you are compiling the right file ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.