Solved Simple object to print output to a windowed screen
So I'm learning C++ but also trying to jump across to GUI.
I am hoping to do this using QT.
So, whilst I am teaching myself C++ I would like to send what I would ordinarily send to a simple text/terminal output to an object within a GUI app.
Can anyone suggest the right QT object to do this?
Can anyone suggest a simple example to print, say, a list of numbers to this object?
JonB last edited by JonB
QListViewwould work. But they display a list of items, so you would (presumably) make each line of output be one item.
To just display text like, say, a terminal/console would do, a QTextEdit displays multiple lines of text (without breaking it into a list).
setAcceptRichText(false)would be suitable to ensure it only deals in plain text. In which case, a QPlainTextEdit would be even simpler. Both of these support scrolling as the content gets large, just like a terminal/soncole. You can also
setReadOnly(true)to make it not allow the user to edit/type into it. Up to you whether you want this or a list of items.
Whichever of these you use, QString QString::arg(int a) accepts an integer and returns it as a decimal string, suitable for putting it into a a list item or into a text edit widget. Or for
QListViewyou can just put the numbers directly into the model and the view will show them as text for you.
Okay, I'll give that a go.