Reputation: 1413
I am working in c++ Qt Creator. I have a form with label
s and lineEdit
s. I would like to set as default in each lineEdit
a text. It would be more efficient than writing the same stuff each time I run the application. Can you please tell me how to do this?
Upvotes: 3
Views: 10011
Reputation: 1
When you double click in the UI designer on the QTextEdit
you can enter a default text which is set every time your application is run.
Alternate you can set the text using setText(QString)
function in the constructor of your window.
Upvotes: 0
Reputation: 39089
Qt has a concept of properties, and for each property, there's usually a getter and a setter, in your case "Text" (as also displayed in the designer) -> void setText(QString)
, QString text()
.
As a serious advice: Learn to use the excellent documentation. Nearly everything in QtCreator lets you open a context-sensitive help via F1. And read some introductions;
Upvotes: 5
Reputation: 3288
Read thorugh the documentation.
Why not just set it to your default value at start? Would be the easiest way if you know how to set a textedit to a value anyhow.
hope this helps, tell me if you need aything more
Upvotes: 0
Reputation: 2882
Use
void setText( const QString & )
You can set it in the constructor or maybe set all those defaults in an init()
function.
Upvotes: 1