$> man42.net Blog written by a human

# Issues

  • You want to share your code logic through a base class.
  • Your code involves emitting signals.
  • You are stuck with the QObject multiple inheritance problem

# Solution

Here is a simple solution: use pure virtual methods instead of signals.

An example:

class DropLogic
{
public:
  virtual ~BaseClass()
  {
  }

  void processDropEvent(QDropEvent *event)
  {
    /* ... do something */

    this->notifySomething();
  }

protected:
  virtual void notifySomething() const = 0;
};

class CustomTableView : public QTableView, public DropLogic
{
signals:
  void notifySomething() const;
};

Moreover, the compiler will tell you if you forgot to declare the signal in your derived class!

Happy coding :)

Buffer this pageShare on TumblrDigg thisShare on FacebookShare on LinkedInTweet about this on TwitterEmail this to someoneShare on Google+Share on RedditPin on Pinterest