Ошибка no matching member function for call to connect

My program was working fine but I wanted to add an extra signal into it to display an updated value. This is the first time the signal was actually coming from the class itself, so I decided to use this as you shall see.

The Program

In my header file, as usual I declare my signal:

signals:
    void NotifyStatusUpdated(const QString& value);

private:

    SetupTab& m_setupTab;
    Instrument& m_instrument;

In the .cpp, the final thing constructed is the signal:

WireMessages();
emit NotifyStatusUpdated(tr("Long wait time (Ms) updated : %1 ").arg(long_wait));

Then below I have this:

void SetupViewManager::WireMessages()
{
    connect(&m_instrument, &Instrument::NotifyErrorDetected,
            &m_setupTab, &SetupTab::onStatusUpdated);       //this works
    connect(&m_instrument, &Instrument::NotifyStatusUpdated,
            &m_setupTab, &SetupTab::onStatusUpdated);       //this works
    connect(this, &Instrument::NotifyStatusUpdated,       //this does not work (it doesn't build)!
            &m_setupTab, &SetupTab::onStatusUpdated);
}

So in my class reference m_instrument, I have another signal which has the same name. So here I want to call the signal from this class instead.

The Error

error: no matching member function for call to 'connect'
        connect(this, &Instrument::NotifyStatusUpdated,
        ^~~~~~~

This just does not seem right to me? What stupid mistake am I making?

Автор Тема: ошибка: no matching member function for call to ‘connect’  (Прочитано 3787 раз)
kambala


надо писать либо

C++ (Qt)

connect(&pClientSoket, SIGNAL(disconnected()), &pClientSoket, SLOT(deleteLater()));

либо

C++ (Qt)

connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);

Записан

Изучением C++ вымощена дорога в Qt.

UTF-8 has been around since 1993 and Unicode 2.0 since 1996; if you have created any 8-bit character content since 1996 in anything other than UTF-8, then I hate you. © Matt Gallagher

Noize_programmer

Чайник
*
Offline Offline

Сообщений: 77

работает не трогай

Просмотр профиля
WWW


если пишу это

   connect(&pClientSoket, SIGNAL(disconnected()), &pClientSoket, SLOT(deleteLater()));

то ошибка:
ошибка: no matching member function for call to ‘connect’

а если пишу это

       connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);

то ошибки:
ошибка: no matching member function for call to ‘connect’

« Последнее редактирование: Февраль 05, 2023, 16:11 от Noize_programmer »
Записан

Официальная стандартизация языка с++ началась в 1998 году, когда был опубликован стандарт языка ISO/IEC 14882:1998(известный как C++98), разработанный комитетом по стандартизации C++(ISO/IEC JTC1/SC22/WG21 working group)

kambala


полная ошибка всегда пишется во вкладке номер 4, без нее ничего не понятно


Записан

Изучением C++ вымощена дорога в Qt.

UTF-8 has been around since 1993 and Unicode 2.0 since 1996; if you have created any 8-bit character content since 1996 in anything other than UTF-8, then I hate you. © Matt Gallagher

Noize_programmer

Чайник
*
Offline Offline

Сообщений: 77

работает не трогай

Просмотр профиля
WWW


полная ошибка всегда пишется во вкладке номер 4, без нее ничего не понятно

вот:
14:32:15: Выполняются этапы для проекта TCP_server…
14:32:15: Настройки не изменились, этап qmake пропускается.
14:32:15: Запускается: «F:Qt5.14Toolsmingw730_64binmingw32-make.exe» -j6

F:/Qt5.14/Tools/mingw730_64/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory ‘F:/Qt_project/5.0.2/lesons/Book/TCP_server/build-TCP_server-Desktop_Qt_5_12_12_MinGW_64_bit-Debug’
g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..TCP_server -I. -IF:Qt5.145.12.12mingw73_64include -IF:Qt5.145.12.12mingw73_64includeQtWidgets -IF:Qt5.145.12.12mingw73_64includeQtGui -IF:Qt5.145.12.12mingw73_64includeQtANGLE -IF:Qt5.145.12.12mingw73_64includeQtNetwork -IF:Qt5.145.12.12mingw73_64includeQtCore -Idebug -I/include -IF:Qt5.145.12.12mingw73_64mkspecswin32-g++  -o debugmyserver.o ..TCP_servermyserver.cpp
..TCP_servermyserver.cpp: In member function ‘virtual void MyServer::SNewConnection()’:
..TCP_servermyserver.cpp:48:94: error: no matching function for call to ‘MyServer::connect(QTcpSocket**, void (QAbstractSocket::*)(), QTcpSocket**, void (QObject::*)())’
     connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);
                                                                                              ^
In file included from
F:Qt5.145.12.12mingw73_64include/QtWidgets/qwidget.h:45:0,
                 from F:Qt5.145.12.12mingw73_64includeQtWidgets/qmainwindow.h:44,
                 from F:Qt5.145.12.12mingw73_64includeQtWidgets/QMainWindow:1,
                 from ..TCP_servermyserver.h:4,
                 from ..TCP_servermyserver.cpp:1:
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:208:36: note: candidate: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
     static QMetaObject::Connection connect(const QObject *sender, const char *signal,
                                    ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:208:36: note:   no known conversion for argument 1 from ‘QTcpSocket**’ to ‘const QObject*’
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:[/color]211:36: note: candidate: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType)
     static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
                                    ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:211:36: note:   no known conversion for argument 1 from ‘QTcpSocket**’ to ‘const QObject*’
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:463:32: note: candidate: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
 inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
                                ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:463:32: note:   no known conversion for argument 1 from ‘QTcpSocket**’ to ‘const QObject*’
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:
228:43: note: candidate: static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (QAbstractSocket::*)(); Func2 = void (QObject::*)(); typename QtPrivate::FunctionPointer<Func>::Object = QAbstractSocket; typename QtPrivate::FunctionPointer<Func2>::Object = QObject]
     static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
                                           ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:228:43: note:   no known conversion for argument 1 from ‘QTcpSocket**’ to ‘const Object* {aka const QAbstractSocket*}’
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:
260:13: note: candidate: template<class Func1, class Func2> static typename std::enable_if<((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0), QMetaObject::Connection>::type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, Func2)
             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
             ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:
260:13: note:   template argument deduction/substitution failed:
..TCP_servermyserver.cpp:
48:94: note:   candidate expects 3 arguments, 4 provided
     connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);
                                                                                              ^
In file included from
F:Qt5.145.12.12mingw73_64include/QtWidgets/qwidget.h:45:0,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/qmainwindow.h:44,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/QMainWindow:1,
                 from
..TCP_servermyserver.h:4,
                 from
..TCP_servermyserver.cpp:1:
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:269:13: note: candidate: template<class Func1, class Func2> static typename std::enable_if<(((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0) && (! QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction)), QMetaObject::Connection>::type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const QObject*, Func2, Qt::ConnectionType)
             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
             ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:269:13: note:   template argument deduction/substitution failed:
..TCP_servermyserver.cpp:48:55: note:   cannot convert ‘& pClientSoket’ (type ‘QTcpSocket**’) to type ‘const QObject*’
     connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);
                                                       ^~~~~~~~~~~~~
In file included from
F:Qt5.145.12.12mingw73_64include/QtWidgets/qwidget.h:45:0,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/qmainwindow.h:44,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/QMainWindow:1,
                 from
..TCP_servermyserver.h:4,
                 from
..TCP_servermyserver.cpp:1:
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:300:13: note: candidate: template<class Func1, class Func2> static typename std::enable_if<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1), QMetaObject::Connection>::type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, Func2)
             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
             ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:300:13: note:   template argument deduction/substitution failed:
..TCP_servermyserver.cpp:48:94: note:   candidate expects 3 arguments, 4 provided
     connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);
                                                                                              ^
In file included from
F:Qt5.145.12.12mingw73_64include/QtWidgets/qwidget.h:45:0,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/qmainwindow.h:44,
                 from
F:Qt5.145.12.12mingw73_64includeQtWidgets/QMainWindow:1,
                 from
..TCP_servermyserver.h:4,
                 from
..TCP_servermyserver.cpp:1:
F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:308:13: note: candidate: template<class Func1, class Func2> static typename std::enable_if<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1), QMetaObject::Connection>::type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const QObject*, Func2, Qt::ConnectionType)
             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
             ^~~~~~~

F:Qt5.145.12.12mingw73_64include/QtCore/qobject.h:308:13: note:   template argument deduction/substitution failed:
..TCP_servermyserver.cpp:48:55: note:   cannot convert ‘& pClientSoket’ (type ‘QTcpSocket**’) to type ‘const QObject*’
     connect(&pClientSoket, &QTcpSocket::disconnected, &pClientSoket, &QTcpSocket::deleteLater);
                                                       ^~~~~~~~~~~~~

..TCP_servermyserver.cpp: In member function ‘void MyServer::SReadClient()’:
..TCP_servermyserver.cpp:67:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(pClientSoket->bytesAvailable() < sizeof (quint16))
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
mingw32-make[1]: *** [Makefile.Debug:487: debug/myserver.o] Error 1
mingw32-make[1]: Leaving directory
‘F:/Qt_project/5.0.2/lesons/Book/TCP_server/build-TCP_server-Desktop_Qt_5_12_12_MinGW_64_bit-Debug’
mingw32-make: *** [Makefile:38: debug] Error 2
14:32:18: Процесс
«F:Qt5.14Toolsmingw730_64binmingw32-make.exe» завершился с кодом 2.
Ошибка при сборке/развёртывании проекта TCP_server (комплект: Desktop Qt 5.12.12 MinGW 64-bit)
Во время выполнения этапа «Сборка»
14:32:18: Прошло времени: 00:03.

« Последнее редактирование: Февраль 06, 2023, 15:00 от Noize_programmer »
Записан

Официальная стандартизация языка с++ началась в 1998 году, когда был опубликован стандарт языка ISO/IEC 14882:1998(известный как C++98), разработанный комитетом по стандартизации C++(ISO/IEC JTC1/SC22/WG21 working group)

kambala


а, так pClientSoket у тебя уже и так указатель, тогда не надо перед ним ставить &

вот почему надо сразу давать максимальную информацию о коде


Записан

Изучением C++ вымощена дорога в Qt.

UTF-8 has been around since 1993 and Unicode 2.0 since 1996; if you have created any 8-bit character content since 1996 in anything other than UTF-8, then I hate you. © Matt Gallagher

Noize_programmer

Чайник
*
Offline Offline

Сообщений: 77

работает не трогай

Просмотр профиля
WWW


а, так pClientSoket у тебя уже и так указатель, тогда не надо перед ним ставить &

вот почему надо сразу давать максимальную информацию о коде

огромное сапсибо за помощь!

p.s.
впредь буду давать больше информации о коде

(я пошёл писать TCP Client)

« Последнее редактирование: Февраль 06, 2023, 15:16 от Noize_programmer »
Записан

Официальная стандартизация языка с++ началась в 1998 году, когда был опубликован стандарт языка ISO/IEC 14882:1998(известный как C++98), разработанный комитетом по стандартизации C++(ISO/IEC JTC1/SC22/WG21 working group)

This topic has been deleted. Only users with topic management privileges can see it.

  • Hello,

    I am trying to use QSignalMapper to map many similar identifiable QLineEdit widgets in my program.
    I am following instructions on this page: https://doc.qt.io/qt-5/qsignalmapper.html#details
    However I get a compilation error (the title). I don’t understand, QWidget inherits from QObject, so the member function exists, but I must be doing something wrong with the parameters. Help :)

    The line that produces this error is: (in the .cpp file)

    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, &QSignalMapper::map);
    

    Here is the source code and header of the class I’m implementing:

    lineedityarnsetpoint.h

    #ifndef LINEEDITYARNSETPOINT_H
    #define LINEEDITYARNSETPOINT_H
    
    #include <QWidget>
    #include <QSignalMapper>
    #include <QLineEdit>
    #include <QGridLayout>
    //#include <QObject>
    
    class LineEditYarnSetpoint : public QWidget
    {
    	Q_OBJECT
    public:
    	LineEditYarnSetpoint(const int n, QWidget *parent = nullptr);
    
    signals:
    	void editingFinished(const int feeder_index);
    
    private:
    	QSignalMapper *signalMapper;
    
    };
    
    #endif // LINEEDITYARNSETPOINT_H
    

    lineedityarnsetpoint.cpp

    #include "lineedityarnsetpoint.h"
    
    LineEditYarnSetpoint::LineEditYarnSetpoint(const int n, QWidget *parent)
    	: QWidget(parent)
    {
    	signalMapper = new QSignalMapper(this);
    
    	QGridLayout *gridLayout = new QGridLayout;
    	for (int i = 0; i < n; ++i)
    	{
    		QLineEdit *lineEdit = new QLineEdit();
    		/*ERROR*/connect(lineEdit, &QLineEdit::editingFinished, signalMapper, &QSignalMapper::map);
    		signalMapper->setMapping(lineEdit, i);
    		gridLayout->addWidget(lineEdit, 0, i);
    	}
    	connect(signalMapper, &QSignalMapper::mappedInt, this, &LineEditYarnSetpoint::editingFinished);
    	setLayout(gridLayout);
    }
    

    Thanks in advance! :)

  • @t-vanbesien said in no matching member function for call to ‘connect’:

    /*ERROR*/connect(lineEdit, &QLineEdit::editingFinished, signalMapper, &QSignalMapper::map);

    void QSignalMapper::map(QObject *sender) expects a QObject *sender parameter. void QLineEdit::editingFinished() does not provide one.

    OIC, void QSignalMapper::map() does not take any parameter. But now there are two slots of the same name which differ only by parameter. Then you may need to use qOverload<>()/QOverload<>::of() to specify which one? Maybe QOverload<>::of<>(&QSignalMapper::map) or QOverload<>::of<void>(&QSignalMapper::map)? (I don’t know how you specify «the one with no parameter»).

    Ah, see https://stackoverflow.com/questions/68552698/connecting-qsignalmapper-qt-5-15-2 ?

    Also, if you had copied and pasted the full error details from the compiler I think it would have said a bit more than just no matching member function for call to 'connect', does it not show information about the various possible slot method overloads?

  • @JonB

    Here is the full error message:

    /Users/thomasvanbesien/IHM_Bobink/lineedityarnsetpoint.cpp:14: error: no matching member function for call to 'connect'
    ../IHM_Bobink/lineedityarnsetpoint.cpp:14:3: error: no matching member function for call to 'connect'
                    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, &QSignalMapper::map);
                    ^~~~~~~
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:181:36: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const char *' for 2nd argument
        static QMetaObject::Connection connect(const QObject *sender, const char *signal,
                                       ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:184:36: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const QMetaMethod' for 2nd argument
        static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
                                       ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:432:41: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const char *' for 2nd argument
    inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
                                            ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:201:43: note: candidate template ignored: couldn't infer template argument 'Func2'
        static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
                                              ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:242:13: note: candidate template ignored: couldn't infer template argument 'Func2'
                connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
                ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:287:13: note: candidate template ignored: couldn't infer template argument 'Func2'
                connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
                ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:233:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided
                connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
                ^
    /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:276:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided
                connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
                ^
    
  • @t-vanbesien said in no matching member function for call to ‘connect’:

    couldn’t infer template argument ‘Func2’

    I’m not sure, but this is probably the one that relates to your situation.
    In any case you need to do the «qoverload» I suggested and is in the SO post.

  • @JonB

    Thank you for the help. I was able to make it work, I changed the erroneous line to:

    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of<>(&QSignalMapper::map));
    

    I’m not completely sure why it works. C++ templates are still a bit fuzzy to me, but I’ll post an explanation when I understand exactly what the problem was.

  • @t-vanbesien said in no matching member function for call to ‘connect’:

    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of<>(&QSignalMapper::map));

    I don’t believe that is a working copy/paste, I think you mean QOverload<>::of(&QSignalMapper::map)?

    C++ templates are still a bit fuzzy to me, but I’ll post an explanation when I understand exactly what the problem was.

    There are 2 possible overloads: QSignalMapper::map() & QSignalMapper::map(QObject *).
    QOverload<>::of(...) picks the first one (no parameters), QOverload<QObject *>::of(...) picks the second one. The bit inside <...> specifies the parameters. It’s kind of like a cast.

  • @JonB said in no matching member function for call to ‘connect’:

    I don’t believe that is a working copy/paste, I think you mean QOverload<>::of(&QSignalMapper::map)?

    No, the line I copy/pasted does compile and run and has the expected behavior.

  • @t-vanbesien
    Interesting. Could you tell me/give me a reference to where you got an example or documentation which uses QOverload<...>::of<...>(...) rather than QOverload<...>::of(...), please? Note the bit I am asking about is the ::of<> having a <...> segment?

  • @JonB
    I don’t know ? I’m not sure I understand the question. I used

    QOverload<...>::of<...>()
    

    because you wrote it in your first answer to this post. I can’t find any documentation about it. If you want a working example I can share the class .cpp and .h of the class and the small debug function I made to make sure it is working properly. You can put it in an empty qt project to check.

  • @t-vanbesien said in no matching member function for call to ‘connect’:

    because you wrote it in your first answer to this post.

    Damn! So I did, I was guessing at that point! :( Now I know better, from the SO link I gave you :)

    I suggest that you try copy/paste the following line to replace yours:

    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of(&QSignalMapper::map));
    

    Even though your ::of<>( apparently works, it should be ::of(. Don’t confuse yourself by using my guessed-syntax, for when you come back to it.

  • @JonB

    I replaced the line so that now it is:

    connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of(&QSignalMapper::map));
    

    And everything is still working properly.

    By the way, you wrote ‘IOC’ in one of your answers, what does it mean ?

  • @t-vanbesien said in no matching member function for call to ‘connect’:

    By the way, you wrote ‘IOC’ in one of your answers, what does it mean ?

    I wrote OIC => O-I-C => «Oh I See» :)

  • QScrollArea, QScrollBar

    Добрый день.

    Я воспользовался прримером

    Image Viewer

    .

    У меня есть

    QScrollArea *scrollArea;
    

    У QScrollArea есть вертикальные и горизонатальные QScrollBar.

    Я хочу к сигналам изменения scrollArea привязать пустой слот:

    connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
    

    Но получаю ошибку: no matching member function for call to ‘connect’

    Скажите пожалуйста, как привязать слот к сигналу изменения QScrollArea?

    Вам это нравится? Поделитесь в социальных сетях!

    No_name0

    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    1

    Проблемы с коннектом

    11.10.2020, 22:10. Показов 599. Ответов 13

    Метки нет (Все метки)


    Студворк — интернет-сервис помощи студентам

    кусочек кода (все либы подключены)

    C++ (Qt)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    Skilet::Skilet(QWidget *parent)
        :QMainWindow(parent) // Конструктор класса каркаса приложения
    {
    QAction *generate = new QAction("One", this);
     QMenu *file;
          file = menuBar()->addMenu("&Пароли"); // Добавляем меню
         file->addAction(generate);
    connect(generate, &QAction::triggered, this, &MainWindow::generates);
    }
    void MainWindow::generates()
    {
        QMessageBox mbox;
        mbox.setText("hello");
        mbox.show();
    }

    в заголовочном файле в паблик-члене написан слот.
    проблема в том что коннект ругается «no matching member function for call to «connect»
    как решить эту проблему?



    0



    _SayHello

    874 / 535 / 175

    Регистрация: 30.07.2015

    Сообщений: 1,739

    11.10.2020, 22:18

    2

    No_name0, прототип в хидере случайно не так опредлен? Если да, то в CPP тоже void надо

    C++ (Qt)
    1
    
    void generates(void)

    Ну и слот должен быть определен после

    C++ (Qt)
    1
    
    public slots:



    1



    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    11.10.2020, 22:32

     [ТС]

    3

    слот определён после public slots, а там где надо передать void в качестве аргумента, то не выходит ничего (((((



    0



    _SayHello

    874 / 535 / 175

    Регистрация: 30.07.2015

    Сообщений: 1,739

    11.10.2020, 22:35

    4

    No_name0, сигнал и слот должны иметь одинаковую сигнатуру. Сигнал такой:

    C++ (Qt)
    1
    
    void QAction::triggered(bool checked = false)

    Значит и слот должен иметь булёвый параметр



    1



    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    11.10.2020, 22:37

     [ТС]

    5

    А не подскажете как преобразовать слот или сигнал в булевый тип? что-то совсем голова не работает



    0



    _SayHello

    874 / 535 / 175

    Регистрация: 30.07.2015

    Сообщений: 1,739

    11.10.2020, 22:39

    6

    No_name0,

    C++ (Qt)
    1
    
    void generates(bool checked);



    1



    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    11.10.2020, 22:45

     [ТС]

    7

    почему-то всё равно не коннектится, от слова совсем



    0



    iSmokeJC

    Am I evil? Yes, I am!

    Эксперт PythonЭксперт Java

    16956 / 9178 / 2634

    Регистрация: 21.10.2017

    Сообщений: 20,897

    12.10.2020, 07:58

    8

    No_name0, твой код работает, даже без правок (в части, касающейся коннекта).
    Поменял в слоте

    C++ (Qt)
    1
    2
    3
    
    QMessageBox *mbox = new QMessageBox;
    mbox->setText("hello");
    mbox->show();

    Проблемы с коннектом



    1



    фрилансер

    4816 / 4419 / 941

    Регистрация: 11.10.2019

    Сообщений: 11,653

    12.10.2020, 08:02

    9

    Цитата
    Сообщение от No_name0
    Посмотреть сообщение

    что коннект ругается «no matching member function for call to «connect»

    ругается где?
    1) анализатор кода?
    2) компилятор?
    3) строка в окне вывода во время запуска?



    1



    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    12.10.2020, 08:30

     [ТС]

    10

    Qt creator.



    0



    1392 / 639 / 295

    Регистрация: 02.05.2020

    Сообщений: 1,490

    12.10.2020, 12:50

    11

    Цитата
    Сообщение от _SayHello
    Посмотреть сообщение

    void generates(void)

    попробуйте static void generates()

    Добавлено через 2 минуты
    по этому скудному отрывку кода не понятно, какое отношение класс Skilet имеет к классу MainWindow



    1



    No_name0

    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    12.10.2020, 16:28

     [ТС]

    12

    C++ (Qt)
    1
    2
    3
    4
    5
    6
    
    class Skilet:public QMainWindow
    {
    public:
       Skilet(QWidget *parent = 0);
     
    };



    0



    2439 / 1178 / 436

    Регистрация: 08.11.2016

    Сообщений: 3,262

    12.10.2020, 17:18

    13

    No_name0, добавьте в класс Skilet макрос Q_OBJECT



    1



    0 / 0 / 0

    Регистрация: 13.07.2020

    Сообщений: 21

    12.10.2020, 18:25

     [ТС]

    14

    Спасибо всем! Каким-то чудом заработало, поменяла отладчики, все пошло как по маслу!



    0



    IT_Exp

    Эксперт

    87844 / 49110 / 22898

    Регистрация: 17.06.2006

    Сообщений: 92,604

    12.10.2020, 18:25

    14

  • Ошибка no match for operator
  • Ошибка no main manifest attribute
  • Ошибка no iwd files found in main
  • Ошибка no hardware found
  • Ошибка no getpropnames function for undefined