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. Cannot run applications from Qt creator
Forum Updated to NodeBB v4.3 + New Features

Cannot run applications from Qt creator

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k 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.
  • S Offline
    S Offline
    santiagorf
    wrote on last edited by
    #1

    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 below

    semaphores.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;
    }@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        santiagorf
        wrote on last edited by
        #3

        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]

        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