Qt-interest Archive, November 2006
Using Forms and Components created from QT Designer with application codes.
Message 1 in thread
Hi All,
I followed the instruction
http://doc.trolltech.com/4.2/designer-using-a-component.html#the-multiple-inheritance-approach
and
get the subclass going well. But I got error "illegal reference to
non-static member 'Ui_MainWindow::labelMainResult' when I try to access the
components from my code.
I defined the subclass in main.h :
class firstMainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
firstMainWindow();
private slots:
void on_pushButton_clicked();
};
I define it In file Module1.cpp :
#include "ui_myUI.h"
QLabel *label = new QLabel;
label = firstMainWindow::labelMainResult
QPointer<QLabel> safeLabel = label; // I got error message ""illegal
reference to non-static member 'Ui_MainWindow::labelMainResult' " here
safeLabel->setText("Hello world!");
All I want to do is that my application can update the text message of
labelMainResult ( on MainWindow) based on running statues. My application
has many modules with different .cpp file, and they all require to update
the labelMainResult text message in run time.
What am missing?
Thanks,
Steve Xu
Message 2 in thread
On 02.11.06 02:35:10, Steve Xu wrote:
> get the subclass going well. But I got error "illegal reference to
> non-static member 'Ui_MainWindow::labelMainResult' when I try to access the
> components from my code.
>
> I define it In file Module1.cpp :
>
> #include "ui_myUI.h"
No need to include the generated header again, as you already have it in
your Module1.h file...
> QLabel *label = new QLabel;
>
> label = firstMainWindow::labelMainResult
>
> QPointer<QLabel> safeLabel = label; // I got error message ""illegal
> reference to non-static member 'Ui_MainWindow::labelMainResult' " here
>
> safeLabel->setText("Hello world!");
Your missing a constructor around these calls and then you won't need
firstMainWindow:: because labelMainResult is directly accessible.
> All I want to do is that my application can update the text message of
> labelMainResult ( on MainWindow) based on running statues. My application
> has many modules with different .cpp file, and they all require to update
> the labelMainResult text message in run time.
>
> What am missing?
I think you're missing basic C++ knowledge, try to find a book about
that first. (Sorry I don't have a hint for a good english book at hand)
Andreas
--
[ signature omitted ]
Message 3 in thread
Andreas Pakulat wrote:
> I think you're missing basic C++ knowledge, try to find a book about
> that first. (Sorry I don't have a hint for a good english book at hand)
Thinking in C++ is awesome.
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Available in PDF and dead tree edition.
-ian reinhart geiser
--
[ signature omitted ]
Message 4 in thread
On 02.11.06 10:16:08, Ian Reinhart Geiser wrote:
> Andreas Pakulat wrote:
>
> > I think you're missing basic C++ knowledge, try to find a book about
> > that first. (Sorry I don't have a hint for a good english book at hand)
> Thinking in C++ is awesome.
> http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Aah, right. I even have that lying around here. But didn't get around to
read it (this qmake stuff really keeps me busy ;)
Andreas
--
[ signature omitted ]
Message 5 in thread
Thanks Ian and Andreas, I learned how to pass a pointer of an instance to my
function. It works now :D
Steve Xu
On 11/2/06, Andreas Pakulat <apaku@xxxxxx> wrote:
>
> On 02.11.06 10:16:08, Ian Reinhart Geiser wrote:
> > Andreas Pakulat wrote:
> >
> > > I think you're missing basic C++ knowledge, try to find a book about
> > > that first. (Sorry I don't have a hint for a good english book at
> hand)
> > Thinking in C++ is awesome.
> > http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
>
> Aah, right. I even have that lying around here. But didn't get around to
> read it (this qmake stuff really keeps me busy ;)
>
> Andreas
>
> --
> You will have a long and unpleasant discussion with your supervisor.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>