PDA

View Full Version : inheritance



steiner
30th October 2007, 18:55
Why can't I do this?



class myTextEdit : public QTextEdit {
//blah
};

class MainWindow : QMainWindow {

private slots:
void getText() {
QString = inputText->text(); //inputText is defined as myTextEdit
}
};


This example is highly contrived, but since QTextEdit has a public function called text(), why does the compiler say it isn't a member of myTextEdit...

Thanks

marcel
30th October 2007, 18:59
I am afraid there's no such member in QTextEdit.
You can use QTextEdit::toPlainText to retrieve the contained text.

jpn
30th October 2007, 19:07
Perhaps you're reading docs of Qt 3 but actually using Qt 4?

steiner
30th October 2007, 20:11
yes, 3.3 specifically it clearly states it has a text() method

jpn
30th October 2007, 20:17
And what does "qmake -v" output? You should read docs of Qt 4 if that's what you use. Qt 3 and Qt 4 are pretty much different. ;)