Hi!

> Can you make an example of your structure (what's exactly in each of the 
> three files)? It's not entirely clear.

Ok, I attached an example of a module containing some pseudo code. Please tell 
me if you
need more information.

> You might also use a custom extra compiler -- that still invokes moc, 
> but for each foo.h also tells moc to include foo.inl, bar.h -> bar.inl, 
> and so on...

Hm, I see. Has something like that been done before, is there code I could 
reuse?

-- 
Best Regards,
Bernhard Lindner
#include "spinbox.inl"

SpinBoxU64::SpinBoxU64(QWidget* pParent) noexcept :
   AbstractSpinBox<quint64>(pParent)
{
}
#ifndef SPINBOX_HPP
#define SPINBOX_HPP

template <typename T>
class AbstractSpinBox : public QAbstractSpinBox
{
   public:
      explicit AbstractSpinBox(QWidget* pParent = nullptr) noexcept;

      T value() const noexcept;
      void setValue(const T& pValue) noexcept;

      T minimum() const noexcept;
      void setMinimum(const T& pMinimum) noexcept;

      T maximum() const noexcept;
      void setMaximum(const T& pMaximum) noexcept;

      ...
};

class SpinBoxU64 : public AbstractSpinBox<quint64>
{
      Q_OBJECT

      Q_PROPERTY(quint64 minimum READ minimum WRITE setMinimum)
      Q_PROPERTY(quint64 maximum READ maximum WRITE setMaximum)
      Q_PROPERTY(quint64 value READ value WRITE setValue NOTIFY valueChanged USER true)

   public:
      explicit SpinBoxU64(QWidget* pParent = nullptr) noexcept;

   signals:
      void valueChanged(const quint64& pValue);

      ...
};

#endif // SPINBOX_HPP
#ifndef SPINBOX_INL
#define SPINBOX_INL

#include "spinbox.hpp"

template <typename T>
AbstractSpinBox<T>::AbstractSpinBox(QWidget* pParent) noexcept :
   QAbstractSpinBox(pParent)
{
   ....
}

template <typename T>
void AbstractSpinBox<T>::setMinimum(const T& pMinimum) noexcept
{
   ....
}

template <typename T>
void AbstractSpinBox<T>::setMaximum(const T& pMaximum) noexcept
{
   ....
}

template <typename T>
void AbstractSpinBox<T>::setValue(const T& pValue) noexcept
{
   ....
}

template <typename T>
inline T AbstractSpinBox<T>::minimum() const noexcept
{
   ....
}

template <typename T>
inline T AbstractSpinBox<T>::maximum() const noexcept
{
   ....
}

template <typename T>
inline T AbstractSpinBox<T>::value() const noexcept
{
   ....
}

#endif // SPINBOX_INL
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to