Cannot run applications from Qt creator
-
Hi all,
I have installed Qt on Linux Mint Debian Edition and tried to run an example from C++ GUI Programming with Qt4 2nd edition.
From qt-creator, I'm able to compile the code, but when I run it from there, I see the terminal without any message.
However, the program runs with no issues and shows the expected output if I run it from the terminal (as a regular user).What's wrong here?
Any help would be much appreciated.Qt Creator 2.5.0
Qt 4.8.2 (64bit)
The code code is belowsemaphores.pro
@TEMPLATE = app
CONFIG += console thread
CONFIG -= app_bundle
SOURCES = semaphores.cpp@semaphores.cpp
@#include <QtCore>
#include <iostream>const int DataSize = 100000;
const int BufferSize = 4096;
char buffer[BufferSize];QSemaphore freeSpace(BufferSize);
QSemaphore usedSpace(0);class Producer : public QThread
{public:
void run();
};void Producer::run()
{
for (int i = 0; i < DataSize; ++i) {
freeSpace.acquire();
buffer[i % BufferSize] = "ACGT"[uint(std::rand()) % 4];
usedSpace.release();
}
}class Consumer : public QThread
{
public:
void run();
};void Consumer::run()
{
for (int i = 0; i < DataSize; ++i) {
usedSpace.acquire();
std::cerr << buffer[i % BufferSize];
freeSpace.release();
}
std::cerr << std::endl;
}int main()
{
Producer producer;
Consumer consumer;
producer.start();
consumer.start();
producer.wait();
consumer.wait();
return 0;
}@ -
Flip the "Run in Terminal" checkbox in Qt creator's Project section (open your project, click Project pane on the left-hand side, then go to Run Settings).
Or install Xterm. Or specify another terminal in Qt Creator settings. Or use qDebug() instead of std::cerr.
-
That seemed to solve the problem, thanks!
[quote author="sierdzio" date="1362342150"]Flip the "Run in Terminal" checkbox in Qt creator's Project section (open your project, click Project pane on the left-hand side, then go to Run Settings).
Or install Xterm. Or specify another terminal in Qt Creator settings. Or use qDebug() instead of std::cerr.[/quote]