Results 1 to 2 of 2

Thread: abstract custome QWidget class

  1. #1
    Join Date
    May 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default abstract custome QWidget class

    I need to make custome QWidget class and make some kind of helper class, how to do it properly


    Qt Code:
    1. class MyWidget : public QWidget, public MyHelper
    To copy to clipboard, switch view to plain text mode 

    The point is that I need to inherit public QObject in MyHelper to have the parent object available. When I will do it compiler complains

    Qt Code:
    1. error: 'QObject' is an ambiguous base of 'ListView'
    To copy to clipboard, switch view to plain text mode 


    When I take this out

    Qt Code:
    1. error: type 'QObject' is not a direct base of 'MyHelper'
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. warning: Class MyObject inherits from two QObject subclasses MyHelper and QWidget. This is not supported!
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. error: Class contains Q_OBJECT macro but does not inherit from QObject
    To copy to clipboard, switch view to plain text mode 

    Is it possible ?

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: abstract custome QWidget class

    You cannot use multiple inheritance of QObject.

    Try using composition.
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 0
    Last Post: 23rd November 2010, 21:54
  2. Replies: 1
    Last Post: 30th October 2010, 13:28
  3. Abstract base class and inherited class members
    By JovianGhost in forum General Programming
    Replies: 3
    Last Post: 19th March 2010, 13:32
  4. MVC - Abstract Widget Base Class - setupUI
    By SenSej in forum Newbie
    Replies: 0
    Last Post: 13th October 2008, 11:44
  5. Replies: 2
    Last Post: 25th August 2006, 12:35

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.