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

List:       kde-multimedia
Subject:    Re: adding properties to a C++ class
From:       Scott Wheeler <scott () slackorama ! net>
Date:       2001-12-17 6:18:12
[Download RAW message or body]

Ok, that makes sense, but still doesn't really get at my question.

I guess a better way of wording my question is:

Is there any way to make a subclass function as a the baseclass even though 
it has more features?

Here's a silly little example that I came up with (that doesn't work).
===
#include <iostream>

class foo {
private:
  int myInt;
public:
  int value() { return(myInt); }
  void setValue(int value) { myInt=value; }
};

class baz : public foo {};

int main() 
{
  foo bar;
  bar.setValue(3);
  cout << bar.value() << endl;
  baz quux;
  quux=bar;
  cout << quux.value() << endl;
  return(0);
}
===

Is there any way to allow class quux to accept assignment from foo?  
Qt-Designer I don't think allows passing derived classes in signals.

Thanks for the help.  I know that these are annoying questions.

-Scott

On Sunday 16 December 2001 06:17 am, Rolf Magnus wrote:
> On Sunday 16 December 2001 07:06, Scott Wheeler wrote:
> > class qtaggerListItem : public QListViewItem
> > {
> > public:
> >   qtaggerListItem(QListView * parent);
> > private:
> >     Q_OBJECT
> >     QString fileName;
> > };
> >
> > But this seems to cause problems because the QListView doesn't seem to
> > like having qtaggerListItems included.  Is there a way around this?
>
> QListViewItem is not derived from QObject, thus you can't use O_OBJECT
> unless you also derive qtaggerListItem from QObject. So make this:
>
> class qtaggerListItem : public QObject, public QListViewItem
>
> or leave the Q_OBJECT out if you don't need signals/slots.
_______________________________________________
kde-multimedia mailing list
kde-multimedia@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-multimedia
[prev in list] [next in list] [prev in thread] [next in thread] 

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