Accessing form element's properties
-
This is the one thing I hate about QT is that I don't know how to do this so I thought I would ask. It for some reason is not as easy as people show. For them the item just auto completes for me I have tried everything I can think of to do this.
-
@AI_Messiah Your description is not clear. Do you mean the auto-completion feature in QtCreator does not work for you?
-
What I mean is that when I try do do something like
QString mystr = ui->textbox1->text;
I know it wouldn't look like this but I am using it as an example. It will not work.
-
@AI_Messiah said in Accessing form element's properties:
It will not work.
In what way? It won't autocomplete in editor? It won't compile? It doesn't behave as expected at runtime?
That should "work" if you do it from the right file. Note that you will want the parentheses as per
QString mystr = ui->textbox1->text();
-
@AI_Messiah said in Accessing form element's properties:
QString mystr = ui->textbox1->text;
Of course it will not work as it's invalid syntax.
It has to be:QString mystr = ui->textbox1->text();
Or do I misunderstand the problem?
-
What I found is that you have to include all of the controls that you want in your application with the first edit of the ui file
-
Hi
We are not sure what you think is not working so good.If you mean Auto completion or something else.
- What I found is that you have to include all of the controls that you want in your application with the first edit of the ui file
This suggests you mean that when you place a widget on the form, then switch
back to code and try
to do
ui->newname->and it won't guess on "newname" ?
if yes, you can press Ctrl+Alt+B
that will build the file and then ui->newname is surely
available. -
What I mean is the first time you edit the form this is when you have to include all of your controls. Otherwise they will not show up when you try to reference them.
-
@AI_Messiah After editing the ui file in designer you should rebuild your project, so the uic compiler generates ui code, then autocomplition should work.