PDA

View Full Version : Ui class errors



calef13
4th November 2007, 13:52
Hello everyone, I am trying to learn Qt4 in linux for a school project, unfortunately I don't have any help from teachers as all we have in school in VB so you guys are my only hope :)

My problem is simple, I can't seem to be able to use the ui:: class at all. I am currently trying to write a simple program using the single inheritance approach as described here: http://doc.trolltech.com/4.3/designer-using-a-component.html
But I have not been able to compile anything as I keep getting the following errors:


learn.h:14: error: ‘Learn’ in namespace ‘Ui’ does not name a type
learn.cpp:8: error: ‘ui’ was not declared in this scope
learn.cpp:13: error: ‘ui’ was not declared in this scope


here is the relevant code from learn.h:


Ui::Learn ui;




ui.setupUi(this);
...
ui.label->setText(ui.lineEdit->text());


I have followed the above links advice to the letter; I have included "ui_learn.h" in learn.h and have included learn.h in both learn.cpp and main.cpp.

I have tried various examples from the Qt4 book from trolltech and the internet and these three errors are always present no matter what I write. I am really stumped. Do I need to wait for KDE4? I have Qt4 and Qt4-doc installed but am running KDE3. Any help or advice would be greatly appreciated.

Thanks in advance,

Calef13

P.S: I am more than happy to post more code if anyone wants to see it.

jpn
4th November 2007, 14:46
Make sure that the objectName-property of the form is "Learn".

calef13
4th November 2007, 14:53
That fixed it, thank you so much. This has been bugging me for ages.