Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Help with "error: no matching function for call to..."
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BasicPoke
    wrote on 28 Oct 2014, 22:14 last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on 29 Oct 2014, 04:16 last edited by
      #2

      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)
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BasicPoke
        wrote on 29 Oct 2014, 13:25 last edited by
        #3

        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

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BasicPoke
          wrote on 29 Oct 2014, 14:12 last edited by
          #4

          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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on 29 Oct 2014, 15:12 last edited by
            #5

            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.

            1 Reply Last reply
            0

            4/5

            29 Oct 2014, 14:12

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved