Help with "error: no matching function for call to..."



  • I need help please with this error.

    @C:\Users\evanron\Documents\Projects\Qt\Gauge Monitor\Source Code\GaugeMon.cpp:73: error: no matching function for call to 'GaugeInfoTypeEH::GaugeInfoTypeEH()'
    GaugeMon::GaugeMon(QWidget *parent) : QMainWindow(parent), ui(new Ui::GaugeMon)
    ^@

    @namespace Ui {
    class GaugeMon;
    }

    class GaugeInfoTypeEH
    {
    private:
    Ui::GaugeMon *ui;
    public:
    GaugeInfoTypeEH(Ui::GaugeMon *ui);
    qint8 state;
    qint8 frame_num;
    quint16 threshold;
    };@

    I added the "Ui" lines into GaugeInfoTypeEH because I want to access the UI on occasion from that class, and I saw something similar done in my "main window" class GaugeMon. Where am I going wrong? The inheritance and the *Ui::GaugeMon ui; lines get me confused.

    Thanks
    Ron



  • A constructor definition in cpp file is not correct. According to declaration in a header file GaugeInfoTypeEH is not derived from QMainWindow and does not accept QWidget. You need to change it to something like this
    @
    GaugeMon::GaugeMon(Ui::GaugeMon* ui) : ui(ui)
    @



  • Thank you andreyc, but GaugeMon has been the same for months and I don't think anything is wrong with it. GaugeInfoTypeEH is new and it is what needs to be changed, I believe.

    @namespace Ui {
    class GaugeMon;
    }

    class GaugeMon : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit GaugeMon(QWidget *parent = 0);
    ~GaugeMon();@

    Why is the compiler indicating a call to GaugeInfoTypeEH::GaugeInfoTypeEH() but pointing to GaugeMon::GaugeMon?
    Ron



  • I figured out my problem. I was declaring a GaugeInfoTypeEH object with no arguments to the constructor:

    @GaugeInfoTypeEH GaugeInfoEH;@

    I changed to the following and it compiles:

    @GaugeInfoTypeEH GaugeInfoEH(Ui::GaugeMon);@

    My intent was to include this, copying from another class, in case this class needs to read a setting from the UI.

    But I don't understand the expression Ui::GaugeMon. Where is Ui declared? It is not in my code, I searched. I thought the namespace but I commented that out. Can someone please help me understand this.
    Thanks
    Ron



  • Glad you resolved compiler issue.
    About Ui::
    If you use qtcreator try to create Qt widget project using qtcreator wizard. It will show how Ui:: is used.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.