<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QObject::connect name conflict with winsock]]></title><description><![CDATA[<p dir="auto">In my client class I've got such piece of code checking if client is connected</p>
<pre><code>void Client::connectToServer() {
    setUpClientAddress();
    initializeSocket();

    if (connect(clientSocket, (SOCKADDR *) &amp;clientAddress, sizeOfClientAddress)) {
        std::cout &lt;&lt; "Failed to connect" &lt;&lt; std::endl;
        return;
    } else { // so on 
</code></pre>
<p dir="auto">But when I'm trying to generate GUI and bind click event I' facing the following issue - "No matching member function for call to 'connect'"</p>
<pre><code>class Client : public QObject{
</code></pre>
<pre><code>/*some code before*/ 
for (const std::string &amp;s: guiInfo) {
            QPushButton *button = new QPushButton(QString::fromStdString(s));
            const QSize BUTTON_SIZE = QSize(40, 40);
            button-&gt;setFixedSize(BUTTON_SIZE);
            QObject::connect(button, SIGNAL(clicked()), this, SLOT(requestScene(s)));

            layout-&gt;addWidget(button);
        }
/*some code after*/ 
</code></pre>
<p dir="auto">How to solve this conflict? Does winsock_32 have his namespace, so it could be solved by QObject::connect and WinSock32::connect?</p>
]]></description><link>https://forum.qt.io/topic/126974/qobject-connect-name-conflict-with-winsock</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Nov 2026 11:00:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/126974.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 May 2021 10:44:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QObject::connect name conflict with winsock on Tue, 25 May 2021 10:48:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/63350541">@<bdi>63350541</bdi></a> said in <a href="/post/661461">QObject::connect name conflict with winsock</a>:</p>
<blockquote>
<p dir="auto">SLOT(requestScene(s)</p>
</blockquote>
<p dir="auto">This is wrong: you can't pass parameters (s in this case) when connecting. Parameters are passed when emitting the signal. If you want to define the parameter when you connect use new connect syntax and C++ lambda:</p>
<pre><code>QObject::connect(button, &amp;QPushButton::clicked, [this, s]() { requestScene(s); });
</code></pre>
]]></description><link>https://forum.qt.io/post/661464</link><guid isPermaLink="true">https://forum.qt.io/post/661464</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 25 May 2021 10:48:30 GMT</pubDate></item><item><title><![CDATA[Reply to QObject::connect name conflict with winsock on Wed, 26 May 2021 07:24:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/661464">QObject::connect name conflict with winsock</a>:</p>
<blockquote>
<p dir="auto"><code>QObject::connect(button, &amp;QPushButton::clicked, [this, s]() { requestScene(s); });</code></p>
</blockquote>
<p dir="auto">I'd like to add one tiny thing to this. Most of the time you will rely on signal/slot connections to be disconnected automatically. In the normal syntax this is done when either the sender or receiver object are deleted. Unfortunately, this version of the lambda syntax circumvents this. However, you can (and should) provide a context object:</p>
<pre><code>QObject::connect(button, &amp;QPushButton::clicked, this, [this,s]() { requestScene(s); });
</code></pre>
<p dir="auto">I am still trying for me to always follow this advice when using lambdas ;-)</p>
]]></description><link>https://forum.qt.io/post/661594</link><guid isPermaLink="true">https://forum.qt.io/post/661594</guid><dc:creator><![CDATA[SimonSchroeder]]></dc:creator><pubDate>Wed, 26 May 2021 07:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to QObject::connect name conflict with winsock on Tue, 25 May 2021 10:56:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> Many thanks for the advise. It helped me.<br />
Btw, I found how to solve the original issue with name conflict . I had to change</p>
<pre><code>    if (connect(clientSocket, (SOCKADDR *) &amp;clientAddress, sizeOfClientAddress)) {
</code></pre>
<p dir="auto">to</p>
<pre><code>    if ( :: connect(clientSocket, (SOCKADDR *) &amp;clientAddress, sizeOfClientAddress)) {
</code></pre>
<p dir="auto">this solved the namespaces problem</p>
]]></description><link>https://forum.qt.io/post/661467</link><guid isPermaLink="true">https://forum.qt.io/post/661467</guid><dc:creator><![CDATA[63350541]]></dc:creator><pubDate>Tue, 25 May 2021 10:56:00 GMT</pubDate></item><item><title><![CDATA[Reply to QObject::connect name conflict with winsock on Tue, 25 May 2021 10:48:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/63350541">@<bdi>63350541</bdi></a> said in <a href="/post/661461">QObject::connect name conflict with winsock</a>:</p>
<blockquote>
<p dir="auto">SLOT(requestScene(s)</p>
</blockquote>
<p dir="auto">This is wrong: you can't pass parameters (s in this case) when connecting. Parameters are passed when emitting the signal. If you want to define the parameter when you connect use new connect syntax and C++ lambda:</p>
<pre><code>QObject::connect(button, &amp;QPushButton::clicked, [this, s]() { requestScene(s); });
</code></pre>
]]></description><link>https://forum.qt.io/post/661464</link><guid isPermaLink="true">https://forum.qt.io/post/661464</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 25 May 2021 10:48:30 GMT</pubDate></item></channel></rss>