Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>It's possible</em>, but C++ prevents passing the OR in the way you're doing it.</p> <p>The problem is that <code>connect</code> takes an argument of type <code>Qt::ConnectionType</code>. <strong>Bitwise OR'ing two values from an enum produces a value of type <code>int</code></strong> (the enum values undergo <em>integer promotion</em> in order to apply the bitwise OR operator). This causes the compile error you're getting:</p> <blockquote> <p>cannot convert parameter 5 from 'int' to 'Qt::ConnectionType'</p> </blockquote> <p>(Remember that in C++ integrals don't automatically convert into enums).</p> <p>So the solution is casting back the result of the OR into the right type, and the right cast to use is <code>static_cast</code>:</p> <pre><code>static_cast&lt;Qt::ConnectionType&gt;(Qt::QueuedConnection | Qt::UniqueConnection) </code></pre> <hr> <p>Now you might ask "why didn't Qt authors think about this"? Well, the fact is that <em><code>Qt::UniqueConnection</code> has been added in Qt 4.6</em>. </p> <p>Before, <code>connect</code> only took a single enum value, not an OR combination of them. That's why <code>connect</code> has this signature:</p> <pre><code>connect(..., Qt::ConnectionType) </code></pre> <p>and not something like this:</p> <pre><code>connect(..., QFlags&lt;Qt::ConnectionType&gt;) connect(..., int) </code></pre> <p>which instead would've allowed the OR. (Note that these latter two signatures also allow for things such as <code>Qt::DirectConnection | Qt::QueuedConnection</code>, which don't make sense).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload