Radik Harutyunyan
Radik Harutyunyan

Reputation: 97

connect function error QT 5

I have a problems with the connect function in qt, I am a beginner. Here is my function

connect( this->page(), &QWebEngineView::loadFinished(), this, OnPopulateJavaScriptObjects() );

I have a class WebView which is where void OnPopulateJavaScriptObjects is declared and implemented .. all functions in one file. so when I am trying to call this function I am getting this error

/home/poker/QTwrapper/main.cpp:40: error: no matching function for call to ‘WebView::loadFinished()’
         connect( this->page(), &QWebEngineView::loadFinished(), this, OnPopulateJavaScriptObjects() );                                                             

AND SO ON... So i know I have a lot of mistakes here... who can help me to explain my mistakes and what can be here the best solution to run this piece of code.

when I am writing connect( this->page(), &QWebEngineView::loadFinished, this, OnPopulateJavaScriptObjects() ); I am getting

/home/poker/QTwrapper/main.cpp:40: error: invalid use of void expression connect( this->page(), &QWebEngineView::loadFinished, this, OnPopulateJavaScriptObjects() ); 

Upvotes: 0

Views: 113

Answers (1)

Michał Walenciak
Michał Walenciak

Reputation: 4369

Replace

connect( this->page(), &QWebEngineView::loadFinished(), this, OnPopulateJavaScriptObjects() );

with

connect( this->page(), &QWebEngineView::loadFinished, this, &OnPopulateJavaScriptObjects );

with () you call a method. When you want its address, do call it.

Upvotes: 1

Related Questions