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. QObject::connect - error: no matching function for call to ... ^
Forum Updated to NodeBB v4.3 + New Features

QObject::connect - error: no matching function for call to ... ^

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 3.4k 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.
  • I Offline
    I Offline
    Ibrahim
    wrote on last edited by
    #1

    Hi;
    My Codes:
    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QMap>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
      Q_OBJECT
    
    public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
    
    private:
      Ui::MainWindow *ui;
      QMap<QString, QString> changes;
    };
    
    #endif // MAINWINDOW_H
    
    

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
    {
      ui->setupUi(this);
    
      connect(ui->lineEdit, SIGNAL(textChanged(QString)), [this](const QString& value) { changes["lineEdit"] = value; }); // I get error here.
    }
    
    MainWindow::~MainWindow()
    {
      delete ui;
    }
    

    I get this error message:

    /home/UserName/My Projects/project1/mainwindow.cpp:12: error: no matching function for call to 'MainWindow::connect(QLineEdit*&, const char*, MainWindow::MainWindow(QWidget*)::<lambda(const QString&)>)'
       connect(ui->lineEdit, SIGNAL(textChanged(QString)), [this](const QString& value) { changes["lineEdit"] = value; });
                                                                                                                        ^
    

    Error Message: Image Link
    Thanks.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      You are mixing two connect syntaxes, you cannot use the old SIGNAL() way with lambdas.
      connect(ui->lineEdit, SIGNAL(textChanged(QString)), [this](const QString& value) { changes["lineEdit"] = value; });
      should become
      connect(ui->lineEdit, &QLineEdit::textChanged, [this](const QString& value) { changes["lineEdit"] = value; });

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      I 1 Reply Last reply
      4
      • VRoninV VRonin

        You are mixing two connect syntaxes, you cannot use the old SIGNAL() way with lambdas.
        connect(ui->lineEdit, SIGNAL(textChanged(QString)), [this](const QString& value) { changes["lineEdit"] = value; });
        should become
        connect(ui->lineEdit, &QLineEdit::textChanged, [this](const QString& value) { changes["lineEdit"] = value; });

        I Offline
        I Offline
        Ibrahim
        wrote on last edited by
        #3

        @VRonin Thanks. It is work.

        1 Reply Last reply
        0

        • Login

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