Note that there are some explanatory texts on larger screens.

plurals
  1. POQt: inherited signal not recognized in subclass
    primarykey
    data
    text
    <p>I have created a base class that provides a common signal for all its subclasses:</p> <pre><code>#include &lt;QWidget&gt; namespace Dino { /** * @brief Base class for all single-value settings editors * * Provides a valueChanged() signal that can be used to propagate changes to * values up to the MainWindow */ class TypeEditor : public QWidget { Q_OBJECT public: explicit TypeEditor(QWidget *parent = 0):QWidget(parent){} signals: void valueChanged(); }; } // namespace Dino </code></pre> <p>In a subclass, I want to have this signal available, but also define a more specific signal with the same name but different arguments:</p> <pre><code>#include "ui/typeeditor.h" namespace Dino { class BoolEditor : public TypeEditor { Q_OBJECT public: explicit BoolEditor(QWidget* parent = 0):TypeEditor(parent){} signals: void valueChanged(bool value); public slots: void setValue(bool value) { emit valueChanged(value); emit valueChanged(); } }; } // namespace Dino </code></pre> <p>The idea is that when only the base class type is known, the generalized signal can be used, which tells that there has been a change in the value. When the exact subclass type is known, another signal is available, which tells the new value.</p> <p>Now, when I try to compile I get an error on the <code>emit valueChanged()</code> stating that there is no function called <code>Dino::BoolEditor::valueChanged()</code>. </p> <p>When I rename the signal in the base class to something else it works, so this seems to be a problem of overloading the signal. I would be interested in the reason for this. Is it some design requirement that I'm not aware of that prevents me from overloading a signal in a subclass, or am I just missing something in the code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload