<SOLVED>NCURSES not working properly from within IDE?

  • The following code compiles and runs within the QTC IDE but does not clear screen.
    @#include <iostream>
    #include "term.h"
    #include "unistd.h"
    #include "ncurses.h"

    using namespace std;

    void Clear_Screen(bool RESET= true);

    int main()
    cout << "Hello World!" << endl;
    cout << "Hello Again!" << endl;
    return 0;

    void Clear_Screen(bool RESET)
    if (!cur_term)
    int result;
    if (result <=0) return;
    if (RESET == true)
    putp(tigetstr( "rs1"));

    As above After succesful compile the run from inside QTC gives
    Hello World!
    Hello Again!
    When run straight from XTerm result is
    Hello Again!

    debug shows "result" with value -1.
    Is it the way that QTC opens the application that is causing this error??
    After some research i believe the TTY being applied by running it from inside QTC and directly from xterm are diff???
    Just guessing?????

  • setupterm() the way you have used it requires the presence of a TERM environment variable which in all likelihood is absent.

    You will also need to set "Run in Terminal" in your project settings in order to get a Curses compatible terminal (the Output Pane in Qt Creator is not).

  • Thanks for your response.

    Already have "Run in Terminal" selected.

    bq. setupterm() the way you have used it requires the presence of a TERM environment variable which in all likelihood is absent.

    so what is the difference between running inside the IDE (absent) vs opening it directly from XTerm (present)??

  • The environment you have told Qt Creator to pass to your program does not contain a TERM environment variable, so one is not present.

    Xterm establishes an environment for its child processes that contains the TERM variable.

  • Where am I telling QTC to pass this environment and can I change it so that running the application works correctly from inside the IDE??

    I am assuming that QTC calls on like a shell program that opens the current project with one or two parameters like the one that
    " Press <return> to close this window" comes from.

    If the program can not be run properly from within the IDE I can not see how this would be a bug?

  • The environment settings are in the same place as the "Run in terminal" option. It is fully configurable with several presets that you can work from.

  • So are you saying that there is an environment setting or parameter that I need to set for this small application to work correctly from within the ide? I would love to know what it is!

  • Solved
    It would appear that you have to insert TERM into your RUN ENVIRONMENT by clicking on ADD. Then give it the value of XTERM.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.