LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2015, 01:50 PM   #1
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Rep: Reputation: 1
Qt program can't open example text file


I'm doing simple file i/o using Qt to test. I prompt the user for a file name, count the lines and output num of lines. The source and example text files are in the same directory. When I run this using Qt, in.open() fails. Running the same program from the terminal works.
I did notice that Qt works if I enter entire path at the prompt, so I copied the text file to the same directory but it doesn't open using just the file name.

Also, I'd like to see the console within the Qt IDE (like on a tab on the bottom) instead of opening a separate terminal. Is this possible?

Last edited by Birdman48; 04-07-2015 at 01:52 PM.
 
Old 04-07-2015, 04:04 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Your input file needs to be in the same directory as the executable if you don't supply a full path to it.

In the left pane of Qt Creator click on "Projects", near the top "Build" should be highlighted, if not click on it. Under "General", if "Shadow build" is checked, you can either uncheck it and the project will be built in your source directory where your input file resides or leave it checked and copy your input file to the build directory.

Quote:
instead of opening a separate terminal
Again under "Projects", near the top click "Run" then uncheck "Run in terminal"

Edit: Reread your post. Sometimes I wonder about my reading comprehension. If "Run in terminal" is unchecked, the prompt for the file name will show up in the application output tab but Qt Creator won't accept input. So unchecking "Run in terminal" will not work for programs requiring user input.

Last edited by norobro; 04-07-2015 at 05:10 PM.
 
Old 04-07-2015, 07:14 PM   #3
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
Great thanks.
One thing: Unchecking run in terminal does run it in the IDE under the editor but I lose user input capability. Is this normal. NP if it is. I can go with the terminal for user input programs.
 
Old 04-07-2015, 07:44 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by Birdman48 View Post
Is this normal.
Yep. See my edit above.

The default terminal emulator is xterm. If you prefer something else you can change it: Tools->Options->Environment->Terminal

I run KDE so I set the terminal emulator to Konsole.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file command sees regular ASCII text file as ASCII Java program text bbraml Linux - Software 6 08-30-2013 08:52 AM
Tried to open a text file and program stops working lalhad21 Programming 3 02-08-2011 07:37 PM
in Pascal: how to exec a program, discard text output or send to text file Valkyrie_of_valhalla Programming 6 05-02-2007 09:50 AM
Text File to Audio File Program ? rvijay General 5 04-10-2006 03:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration