Results 1 to 5 of 5

Thread: inheritance

  1. #1

    Angry inheritance

    Why can't I do this?

    Qt Code:
    1. class myTextEdit : public QTextEdit {
    2. //blah
    3. };
    4.  
    5. class MainWindow : QMainWindow {
    6.  
    7. private slots:
    8. void getText() {
    9. QString = inputText->text(); //inputText is defined as myTextEdit
    10. }
    11. };
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: inheritance

    I am afraid there's no such member in QTextEdit.
    You can use QTextEdit::toPlainText to retrieve the contained text.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: inheritance

    Perhaps you're reading docs of Qt 3 but actually using Qt 4?
    J-P Nurmi

  4. #4

    Default Re: inheritance

    yes, 3.3 specifically it clearly states it has a text() method

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: inheritance

    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.
    J-P Nurmi

Similar Threads

  1. Object and multiple inheritance for interfaces
    By brcain in forum Qt Programming
    Replies: 8
    Last Post: 29th June 2021, 15:29
  2. How much inheritance do you use?
    By Michiel in forum General Programming
    Replies: 8
    Last Post: 1st August 2006, 22:29
  3. Inheritance and QpaintEvent
    By djoul in forum Qt Programming
    Replies: 22
    Last Post: 5th July 2006, 13:56
  4. Multiple Inheritance & Qt
    By kefeng.chen in forum Qt Programming
    Replies: 8
    Last Post: 21st March 2006, 18:37
  5. Multiple inheritance & Qt
    By dublet in forum Qt Programming
    Replies: 11
    Last Post: 8th March 2006, 08:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.