0

I'm currently trying to make a Qt console program work with ncurses. I would like to enjoy the advantages of ncurses while still being able to use QTextStream for input and output.

The idea is to use while((c = getch())..... for one particular type of input, while using QTextStream(stdin) for other types of input.

The thing is, if I proceed as follows:

initscr();
//do ncurses stuff
//do QTextStream(stdout) stuff
//do QTextStream(stdin) stuff

I get the following result:enter image description here

However, if I do this:

initscr();
//do ncurses stuff
endwin();
//do QTextStream(stdout) stuff
//do QTextStream(stdin) stuff

The result looks much more appropriate: enter image description here

My question is if the same result can be achieved without the repeated calling of initscr(); and endwin(); every time I want to receive a specific type of input (this is dome relatively often in the program). And if not, are there any pitfalls to this? I know it definitely is not a decent programming practice, but can it have consequences beyond that? The effect on performance is not noticable, at least.

user129186
  • 1,156
  • 2
  • 14
  • 30
  • If you have any specific questions/aspects that make this not a duplicate, let us know by editing your question to deduplicate it. – Kuba hasn't forgotten Monica Aug 02 '16 at 13:22
  • So, will using the approach you have linked have no adverse effects on how QTextStream works? Will its output be placed correctly, like in the second image? – user129186 Aug 02 '16 at 13:37
  • Just try it. It works at least for the simple output I've tried it with. If you have a more complex case, you probably should reimplement the message handler to use `printw()` or somesuch instead of suspending curses like you do. Also since you presumably don't integrate with event loop, so your code will be very awkward. In any case, you should add a simple test case to your question that demonstrates the issue (if it's longer than 100 lines, you're doing it wrong). – Kuba hasn't forgotten Monica Aug 02 '16 at 14:07
  • Actually: (1) he's asking a different question and (2) I'm unconvinced that your answer is correct. – Thomas Dickey Aug 02 '16 at 20:13

0 Answers0