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

List:       kde-devel
Subject:    Re: No KListView Slot
From:       Ravi <ravi () kde ! org>
Date:       2003-12-28 18:48:36
[Download RAW message or body]


> > > No such slot KListView::loadSettings()
> >
> > Well, there is no slot named loadSettings() in KListView. Is it defined
> > in an inherited class? If so, you must have forgotten the Q_OBJECT macro
> > and the inclusion of the generated moc file in the inherited class
> > because the connect() function sees as object of KListView class rather
> > than your inherited class.
>
> hm .. if i put the makro in the header file and #include "class.moc" in the
> source file, the compiler says: class.moc: no such file or directory
>
> did i forgot something?
>
> i am currently not so familiar with the q_object stuff and how does it work
> internally

I'd strongly suggest that you read the Qt tutorial (in its online 
documentation), especially the part about signals and slots. Also, look at 
the KDE application tutorials on http://developer.kde.org to get an idea of 
MOC usage.

That said, here is the quick and dirty way to make it work. Add the Q_OBJECT 
macro in your derived class like so:

class MyListView : public KListView
{
  Q_OBJECT
public:
  [...]
public slots:
  void loadSettings();
  [...]
};

Then, use the moc on the header file:
       moc -o mylistview.moc mylistview.h
and then, add the following line at the end of your implementation in 
mylistview.cpp:
       #include "mylistview.moc"

Running the moc is taken care of automatically if you use the KDE build 
system. In your Makefile.am, add the line
  METASOURCES = AUTO
and then just make sure you have the Q_OBJECT macro and the include file as 
shown above. You might need to rerun
  make -f Makefile.cvs && configure
in order for the build system to catch the modifications.

Regards,
Ravi

 
>> 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