开发者

Trying to get signals to work in my QT. I need some advice and help

开发者 https://www.devze.com 2022-12-12 14:55 出处:网络
So I have in my main function: string s = \"\\nWelcome to Rawr\\n\"; const QString output(s); **emit output(output);<<<<<<<<<<<<<<<<<<&l开发者_开

So I have in my main function:

string s = "\nWelcome to Rawr\n";
const QString output(s);
**emit output(output);       <<<<<<<<<<<<<<<<<<&l开发者_开发技巧t;<<<<<<<<<<<< Getting an error here**

I have set up a Signal in QT Desginer named: output(const QString &s)

My receiver for the signal is my "Form"... in my form.h i have: The slot is called "changeOutput(const QString &s).

void Client::changeOutput(const QString &s)
{
    output_box.setText(s);
}

output_box is a QTextEdit box.

The error I am receiving is : TCPClient.cpp:122: error: no match for call to ‘(const QString) (const QString&)’

What am I doing wrong?

Thanks :)


Since you declared a variable output, the name output refers to that variable in the local scope. The compiler doesn't know that in output(output) you want one output to refer to the variable and the other output to refer to the slot/method.

Use a different name for the local variable to avoid this collision.

0

精彩评论

暂无评论...
验证码 换一张
取 消