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. <SOLVED>NCURSES not working properly from within IDE?

<SOLVED>NCURSES not working properly from within IDE?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 3.2k Views
  • 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.
  • I Offline
    I Offline
    iamk2
    wrote on last edited by
    #1

    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()
    {
    Clear_Screen();
    cout << "Hello World!" << endl;
    Clear_Screen();
    cout << "Hello Again!" << endl;
    return 0;
    }

    void Clear_Screen(bool RESET)
    {
    if (!cur_term)
    {
    int result;
    setupterm(NULL,STDOUT_FILENO,&result);
    if (result <=0) return;
    }
    putp(tigetstr("clear"));
    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?????

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iamk2
        wrote on last edited by
        #3

        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)??

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            iamk2
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • I Offline
                I Offline
                iamk2
                wrote on last edited by
                #7

                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!

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  iamk2
                  wrote on last edited by
                  #8

                  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.

                  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