How do I edit the properties of controls made using QTCreator in Slot declaration?
I made a form using QTCreator. Then I change some of its properties in class constructor like
ui->cancelButton->hide();
It work. Now I declare a custom slot in header file & tried to use controls' properties in Slot implementation in class file (i.e .cpp) like
oldName = lineEDit->text();
but I get error msg
error: 'LineEdit' was not declared in this scope
then I tried like
oldName = ui->nameLine->text();
b开发者_运维问答ut it gives same error. How do I use controls' properties in Slots declaration or other functions when I made UI using Designer ??
EDIT: SLOT SOURCE
void addressbook::addContact()
{
oldName = ui->nameLine->text(); //nameLine->text();
oldAddress = ui->addressText->toPlainText(); //addressText->toPlainText();
nameLine->clear();
addressText->clear();
updateInterface(AddingMode);
}
if you creating class Test it would produce 4 files:
1) test.h - your class header
2) test.cpp - your implementation
3) test.ui - form descriptor
4) ui_test.h - file generated from form descriptor,
containing cpp code to create it.
test_ui.h has a class declaration inside, with the set of members with types and names of objects you put on form. Ui::TestClass
your main class will have it as private member
private:
Ui::TestClass ui;
so if you want to adress form elements do it as ui->ObjectNameFromForm
And - have a look onto your ui_*.h classes, it is normal cpp code, and after researching them you may understand much more clear how forms works.
精彩评论