[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KListView compile error
From:       Johan Grahn <johan () cgeek ! net>
Date:       2007-05-22 13:46:26
Message-ID: 200705221546.26828.johan () cgeek ! net
[Download RAW message or body]

On Tuesday 22 May 2007 15.29.34 Jonas Widarsson wrote:
> On 5/22/07, Johan Grahn <johan@cgeek.net> wrote:
> > I get this when trying to hide headers in a KListView:
> >
> > /home/highlander/projects/kmpc/src/KmpcWindow.cpp: In
> > constructor 'KmpcWindow::KmpcWindow(QWidget*)':
> > /home/highlander/projects/kmpc/src/KmpcWindow.cpp:17: error: invalid use
> > of incomplete type 'struct QHeader'
> > /opt/qt/include/qlistview.h:50: error: forward declaration of 'struct
> > QHeader' make[2]: *** [src/CMakeFiles/kmpc.dir/KmpcWindow.o] Error 1
> >
> >
> > Code:
> >
> > KmpcWindow::KmpcWindow(QWidget *parent)
> >
> >         : QVBox(parent, "test")
> >
> > {
> >
> >         // Setup the playlist controller
> >         m_playlist = new KListView(this);
> >         m_playlist->addColumn("Song");
> >         m_playlist->header()->hide();
>
> incomplete type means that m_playlist->header() returns a pointer to
> QHeader but QHeader is not defined yet.
>
> This is usually because of this:
>
> class QHeader;
> class KListView{
> ...
>    QHeader * header();
> }
>
> You can see QHeader is declared but not completely defined. What you
> need to do is to include the header for QHeader in your cpp-file, so
> that the compiler understands what m_playlist->header() really means.
> This is done in order to minimise unnecessary includes in headers.
> This means you should also do that yourself if you have a member in
> your class declaration that only is a pointer to a Class. Then you'll
> reduce compile times.
>
> It is also a way to avoid recursive includes, but that is another topic.

Thanks alot for the big answer! I learned a new thing today :)

>
> /Jonas
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<


 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic