Results 1 to 12 of 12

Thread: How to extend a class ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Quote Originally Posted by jacek
    How do you build your application? Do you use qmake?
    I use a little tool called qt-prebuild which is fully functionnal because I already compiled other Qt based programs very well without difficulties so it must call qmake nicely to do that.

    edit: of course that program run uic.exe, moc.exe and so on... all what's needed to compile.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Quote Originally Posted by agent007se
    I already compiled other Qt based programs very well without difficulties so it must call qmake nicely to do that.
    Are you sure that there are no other errors? Maybe your compiler can't find Qt headers?
    Last edited by jacek; 26th June 2006 at 19:30.

  3. #3
    Join Date
    May 2006
    Location
    Bangalore
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Try putting this on line 18 of MOC'ed file.

    Qt Code:
    1. typedef unsigned int uint
    To copy to clipboard, switch view to plain text mode 

    Then we might get other errors due to some Qt include related configuration.
    The Keyboard Is Mightier Than The Sword!

  4. #4
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: How to extend a class ?

    Quote Originally Posted by bits
    Try putting this on line 18 of MOC'ed file.

    Qt Code:
    1. typedef unsigned int uint
    To copy to clipboard, switch view to plain text mode 

    Then we might get other errors due to some Qt include related configuration.
    That wasn't the problem !

    I solved the problem with deleting all "crap" files that weren't needed anymore and now it works BUT I have a new problem which fit nicely with the title of this topic so we can continue now :

    here is the output :

    Linking executable: C:\test\app.exe
    .objs\moc_qlistviewext.o:moc_qlistviewext.cpp.rdata$_ZTV12QListViewExt[vtable for QListViewExt]+0x14): undefined reference to `QListViewExt::~QListViewExt()'
    .objs\moc_qlistviewext.o:moc_qlistviewext.cpp.rdata$_ZTV12QListViewExt[vtable for QListViewExt]+0x18): undefined reference to `QListViewExt::~QListViewExt()'
    .objs\moc_qlistviewext.o:moc_qlistviewext.cpp.rdata$_ZTV12QListViewExt[vtable for QListViewExt]+0x190): undefined reference to `non-virtual thunk to QListViewExt::~QListViewExt()'
    .objs\moc_qlistviewext.o:moc_qlistviewext.cpp.rdata$_ZTV12QListViewExt[vtable for QListViewExt]+0x194): undefined reference to `non-virtual thunk to QListViewExt::~QListViewExt()'
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 10 seconds)
    0 errors, 0 warnings
    I think that the better thing to do is restarting a new and clean project file because I'll use a QTreeWidget which have the function I wanted so that I don't need to extend anything !

    Thanks for trying to help me !

    Oh, last thing, can you say me if there is a "default" structure of tree in QTreeView like in QTreeWidget ?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Quote Originally Posted by agent007se
    undefined reference to `QListViewExt::~QListViewExt()'
    Maybe you forgot to implement the destructor?

  6. #6
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Quote Originally Posted by jacek
    Maybe you forgot to implement the destructor?
    Please, can you give me a minimal implementation of qlistviewext.cpp in regard of the qlistviewext.h ?

    I have some difficulties to do that because I'm just beginning with "serious" things with Qt !!

    I'll give you a thank just after that !!

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Quote Originally Posted by agent007se
    Please, can you give me a minimal implementation of qlistviewext.cpp in regard of the qlistviewext.h ?
    Qt Code:
    1. QListViewExt::QListViewExt( QWidget *parent, const char *name )
    2. : QListView( parent )
    3. {
    4. setObjectName( name );
    5. }
    6.  
    7. QListViewExt::~QListViewExt()
    8. {
    9. // empty
    10. }
    To copy to clipboard, switch view to plain text mode 
    Your constructor signature looks like if you were trying to use Qt3, not Qt4. Qt4 doesn't use name parameter in widget constructors.

  8. The following user says thank you to jacek for this useful post:

    agent007se (27th June 2006)

  9. #8
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to extend a class ?

    Well, it work like a charm now .

    - Removed the name because I was using an old howto !
    - Added the desctructor

    Thanks again !

Similar Threads

  1. How can i prevent class redefinition problem ?
    By ankurjain in forum General Programming
    Replies: 5
    Last Post: 26th May 2006, 02:35
  2. Replies: 2
    Last Post: 4th May 2006, 19:17
  3. Qt in other class
    By Morea in forum Qt Programming
    Replies: 4
    Last Post: 9th April 2006, 17:08
  4. How to propagate from one class to another
    By mahe2310 in forum Qt Programming
    Replies: 15
    Last Post: 20th March 2006, 01:27
  5. Replies: 5
    Last Post: 15th March 2006, 07:33

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
  •  
Qt is a trademark of The Qt Company.