Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 439

python-qt4-doc-4.10.3-3.mga4.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Potential Incompatibilities with Earlier Versions &mdash; PyQt 4.10.3 Reference Guide</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '4.10.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/logo_tn.ico"/>
    <link rel="top" title="PyQt 4.10.3 Reference Guide" href="index.html" />
    <link rel="next" title="Installing PyQt4" href="installation.html" />
    <link rel="prev" title="Introduction" href="introduction.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installing PyQt4"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="introduction.html" title="Introduction"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">PyQt 4.10.3 Reference Guide</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="potential-incompatibilities-with-earlier-versions">
<h1>Potential Incompatibilities with Earlier Versions<a class="headerlink" href="#potential-incompatibilities-with-earlier-versions" title="Permalink to this headline">¶</a></h1>
<div class="section" id="pyqt4-v4-9-2">
<h2>PyQt4 v4.9.2<a class="headerlink" href="#pyqt4-v4-9-2" title="Permalink to this headline">¶</a></h2>
<div class="section" id="qpynullvariant">
<h3>QPyNullVariant<a class="headerlink" href="#qpynullvariant" title="Permalink to this headline">¶</a></h3>
<p>In previous versions a <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> would always evaluate to <tt class="docutils literal"><span class="pre">True</span></tt>
when converted to a bool.</p>
<p>In this version a <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> will always evaluate to <tt class="docutils literal"><span class="pre">False</span></tt> when
converted to a bool.  This makes it behave like <tt class="docutils literal"><span class="pre">None</span></tt> in these
circumstances.</p>
</div>
</div>
<div class="section" id="pyqt4-v4-8-3">
<h2>PyQt4 v4.8.3<a class="headerlink" href="#pyqt4-v4-8-3" title="Permalink to this headline">¶</a></h2>
<div class="section" id="sql-models">
<h3>SQL Models<a class="headerlink" href="#sql-models" title="Permalink to this headline">¶</a></h3>
<p>In previous versions, when using v2 of the QVariant API (the default for Python
v3), there was no way to represent a null <tt class="docutils literal"><span class="pre">QVariant</span></tt>.  Therefore when reading
values of certain types from an SQL model it was impossible to distinguish
between, for example, a null integer and an integer with the value zero.</p>
<p>In this version the <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> class is used to represent a null
QVariant.  Therefore the object read from an SQL model may now be a
<tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> instance.</p>
<p>A null <tt class="docutils literal"><span class="pre">QVariant</span></tt> is only converted to a <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> if the underlying
C++ type of the <tt class="docutils literal"><span class="pre">QVariant</span></tt> cannot be tested for null, i.e. it does not
implement an <tt class="docutils literal"><span class="pre">isNull()</span></tt> method.  This ensures that existing code that uses
non-SQL models will continue to work unchanged.</p>
</div>
</div>
<div class="section" id="pyqt4-v4-8">
<h2>PyQt4 v4.8<a class="headerlink" href="#pyqt4-v4-8" title="Permalink to this headline">¶</a></h2>
<div class="section" id="qvariantlist">
<h3>QVariantList<a class="headerlink" href="#qvariantlist" title="Permalink to this headline">¶</a></h3>
<p>In previous versions PyQt4 would always try and convert a Python list to a
<tt class="docutils literal"><span class="pre">QVariantList</span></tt>.  In this version PyQt4 will first try to convert it to a
<tt class="docutils literal"><span class="pre">QVariant</span></tt> containing a <tt class="docutils literal"><span class="pre">QList&lt;QObject</span> <span class="pre">*&gt;</span></tt>, but only if
<tt class="docutils literal"><span class="pre">QList&lt;QObject</span> <span class="pre">*&gt;</span></tt> has been registered with Qt as a meta-type.</p>
<p>Normally it is only the <tt class="xref py py-mod docutils literal"><span class="pre">QtDeclarative</span></tt> module that registers this
meta-type and so the behaviour of existing applications should be unchanged.
It is possible however that you might observe different conversion behaviour
after importing the <tt class="xref py py-mod docutils literal"><span class="pre">QtDeclarative</span></tt> module.</p>
</div>
</div>
<div class="section" id="pyqt4-v4-7-4">
<h2>PyQt4 v4.7.4<a class="headerlink" href="#pyqt4-v4-7-4" title="Permalink to this headline">¶</a></h2>
<div class="section" id="pyqtsignal-with-dict-and-list">
<h3><a class="reference internal" href="new_style_signals_slots.html#PyQt4.QtCore.pyqtSignal" title="PyQt4.QtCore.pyqtSignal"><tt class="xref py py-func docutils literal"><span class="pre">pyqtSignal()</span></tt></a> with dict and list<a class="headerlink" href="#pyqtsignal-with-dict-and-list" title="Permalink to this headline">¶</a></h3>
<p>In previous versions a Qt signal defined using
<a class="reference internal" href="new_style_signals_slots.html#PyQt4.QtCore.pyqtSignal" title="PyQt4.QtCore.pyqtSignal"><tt class="xref py py-func docutils literal"><span class="pre">pyqtSignal()</span></tt></a> that had an argument specified as a dict then,
when emitting a value, PyQt4 would try and convert the value to a
<tt class="docutils literal"><span class="pre">QVariantMap</span></tt> if possible.  If it wasn&#8217;t possible, normally because the dict
had non-string keys, then the value would be left as a dict object.</p>
<p>In this version PyQt4 will not attempt to convert the value to a
<tt class="docutils literal"><span class="pre">QVariantMap</span></tt> and will always leave it as a dict object.  If you want the
value to be converted to a <tt class="docutils literal"><span class="pre">QVariantMap</span></tt> then define the signal argument as
<tt class="docutils literal"><span class="pre">'QVariantMap'</span></tt>.</p>
<p>The same applies to conversions between lists and <tt class="docutils literal"><span class="pre">QVariantList</span></tt>.</p>
</div>
</div>
<div class="section" id="pyqt4-v4-7-1">
<h2>PyQt4 v4.7.1<a class="headerlink" href="#pyqt4-v4-7-1" title="Permalink to this headline">¶</a></h2>
<div class="section" id="qvariant">
<h3>QVariant<a class="headerlink" href="#qvariant" title="Permalink to this headline">¶</a></h3>
<p>This version introduces a slight incompatibility in the conversion between
sub-classes of standard Python types and <tt class="docutils literal"><span class="pre">QVariant</span></tt>.</p>
<p>Take, for example, the following code:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PyQt4.QtCore</span> <span class="kn">import</span> <span class="n">QVariant</span>

<span class="k">class</span> <span class="nc">MyFloat</span><span class="p">(</span><span class="nb">float</span><span class="p">):</span>
    <span class="k">pass</span>

<span class="n">myfloat</span> <span class="o">=</span> <span class="n">MyFloat</span><span class="p">(</span><span class="mf">5.0</span><span class="p">)</span>
<span class="n">variant</span> <span class="o">=</span> <span class="n">QVariant</span><span class="p">(</span><span class="n">myfloat</span><span class="p">)</span>
</pre></div>
</div>
<p>With this version of PyQt4 <tt class="docutils literal"><span class="pre">myfloat</span></tt> will be converted in such a way as to
preserve any additional attributes (including methods) and will not be
converted to a C++ <tt class="docutils literal"><span class="pre">double</span></tt>.  In other words, the following assertions are
true:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">type</span><span class="p">()</span> <span class="o">!=</span> <span class="n">QVariant</span><span class="o">.</span><span class="n">Double</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">()</span> <span class="ow">is</span> <span class="n">myfloat</span><span class="p">)</span>
</pre></div>
</div>
<p>Prior to this version <tt class="docutils literal"><span class="pre">myfloat</span></tt> would be converted to a C++ <tt class="docutils literal"><span class="pre">double</span></tt>.  In
other words, the following assertions would be true:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">type</span><span class="p">()</span> <span class="o">==</span> <span class="n">QVariant</span><span class="o">.</span><span class="n">Double</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">()</span> <span class="o">==</span> <span class="n">myfloat</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">())</span> <span class="ow">is</span> <span class="nb">float</span><span class="p">)</span>
</pre></div>
</div>
<p>The same change also affects objects that implement the sequence protocol.
Prior to this version such an object would be converted to a <tt class="docutils literal"><span class="pre">QVariantList</span></tt>
which would mean that it was converted back to a Python <tt class="docutils literal"><span class="pre">list</span></tt> rather than to
the original type.</p>
</div>
</div>
<div class="section" id="pyqt4-v4-5">
<h2>PyQt4 v4.5<a class="headerlink" href="#pyqt4-v4-5" title="Permalink to this headline">¶</a></h2>
<div class="section" id="id1">
<h3>QVariant<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>This version introduces a slight incompatibility in the conversion between
Python sub-classes of certain Qt classes and <tt class="docutils literal"><span class="pre">QVariant</span></tt>.  The Qt classes
affected are those that <tt class="docutils literal"><span class="pre">QVariant</span></tt> has explicit support for, e.g. <tt class="docutils literal"><span class="pre">QSize</span></tt>,
<tt class="docutils literal"><span class="pre">QBitmap</span></tt>.</p>
<p>Take, for example, the following code:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PyQt4.QtCore</span> <span class="kn">import</span> <span class="n">QSize</span><span class="p">,</span> <span class="n">QVariant</span>

<span class="k">class</span> <span class="nc">MySize</span><span class="p">(</span><span class="n">QSize</span><span class="p">):</span>
    <span class="k">pass</span>

<span class="n">mysize</span> <span class="o">=</span> <span class="n">MySize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="n">variant</span> <span class="o">=</span> <span class="n">QVariant</span><span class="p">(</span><span class="n">mysize</span><span class="p">)</span>
</pre></div>
</div>
<p>With this version of PyQt4 <tt class="docutils literal"><span class="pre">mysize</span></tt> will be converted in such a way as to
preserve any additional attributes (including methods) and will not be
converted to a C++ <tt class="docutils literal"><span class="pre">QSize</span></tt> instance.  In other words, the following
assertions are true:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">type</span><span class="p">()</span> <span class="o">!=</span> <span class="n">QVariant</span><span class="o">.</span><span class="n">Size</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">()</span> <span class="ow">is</span> <span class="n">mysize</span><span class="p">)</span>
</pre></div>
</div>
<p>Prior to this version <tt class="docutils literal"><span class="pre">mysize</span></tt> would be converted to a C++ <tt class="docutils literal"><span class="pre">QSize</span></tt>
instance.  In other words, the following assertions would be true:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">type</span><span class="p">()</span> <span class="o">==</span> <span class="n">QVariant</span><span class="o">.</span><span class="n">Size</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">()</span> <span class="o">==</span> <span class="n">mysize</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">variant</span><span class="o">.</span><span class="n">toPyObject</span><span class="p">())</span> <span class="ow">is</span> <span class="n">QSize</span><span class="p">)</span>
</pre></div>
</div>
<p>It is hoped that this change of behaviour will not have a significant impact.
However if you need the old behaviour then simply create a copy of your
sub-class instance using the base class constructor as shown below:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">variant</span> <span class="o">=</span> <span class="n">QVariant</span><span class="p">(</span><span class="n">QSize</span><span class="p">(</span><span class="n">mysize</span><span class="p">))</span>
</pre></div>
</div>
<p>A similar issue also affects the conversion of the Python <tt class="docutils literal"><span class="pre">datetime</span></tt>,
<tt class="docutils literal"><span class="pre">date</span></tt> and <tt class="docutils literal"><span class="pre">time</span></tt> types to <tt class="docutils literal"><span class="pre">QVariant</span></tt>.  These are no longer converted to
the corresponding <tt class="docutils literal"><span class="pre">QDateTime</span></tt>, <tt class="docutils literal"><span class="pre">QDate</span></tt> and <tt class="docutils literal"><span class="pre">QTime</span></tt> classes.  The values
can be retrieved using <tt class="docutils literal"><span class="pre">QVariant.toPyObject()</span></tt>.  Again, the old behaviour can
be achieved using an explicit conversion to the Qt class before converting to
<tt class="docutils literal"><span class="pre">QVariant</span></tt>.</p>
<p>A further incompatible change is the handling of Python sub-classes of
<tt class="docutils literal"><span class="pre">QObject</span></tt>.  In previous versions <tt class="docutils literal"><span class="pre">QVariant.userType()</span></tt> would return an
internal type and an extra reference would be kept to the Python object.  In
the current version <tt class="docutils literal"><span class="pre">QVariant.userType()</span></tt> will correctly return
<tt class="docutils literal"><span class="pre">QMetaType.QObjectStar</span></tt> (or <tt class="docutils literal"><span class="pre">QMetaType.QWidgetStar</span></tt>) but an extra
reference to the Python object is not kept.  To avoid a potential crash you
should ensure that you keep a separate reference to the Python object, either
explicitly or implicitly by giving it a parent.</p>
</div>
<div class="section" id="pyrcc4-support-for-python-v3">
<h3><strong class="program">pyrcc4</strong> Support for Python v3<a class="headerlink" href="#pyrcc4-support-for-python-v3" title="Permalink to this headline">¶</a></h3>
<p><strong class="program">pyrcc4</strong> will now generate code for Python v3 when the new
<a class="reference internal" href="resources.html#cmdoption-pyrcc4-py3"><em class="xref std std-option">-py3</em></a> command line option is used.  The generated code
will also work with Python v2.6 and later.</p>
<p>By default <strong class="program">pyrcc4</strong> will generate code for all Python v2 versions but
you should use the new <a class="reference internal" href="resources.html#cmdoption-pyrcc4-py2"><em class="xref std std-option">-py2</em></a> command line option to
enforce this in case the default is changed in the future.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Potential Incompatibilities with Earlier Versions</a><ul>
<li><a class="reference internal" href="#pyqt4-v4-9-2">PyQt4 v4.9.2</a><ul>
<li><a class="reference internal" href="#qpynullvariant">QPyNullVariant</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pyqt4-v4-8-3">PyQt4 v4.8.3</a><ul>
<li><a class="reference internal" href="#sql-models">SQL Models</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pyqt4-v4-8">PyQt4 v4.8</a><ul>
<li><a class="reference internal" href="#qvariantlist">QVariantList</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pyqt4-v4-7-4">PyQt4 v4.7.4</a><ul>
<li><a class="reference internal" href="#pyqtsignal-with-dict-and-list"><tt class="docutils literal"><span class="pre">pyqtSignal()</span></tt> with dict and list</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pyqt4-v4-7-1">PyQt4 v4.7.1</a><ul>
<li><a class="reference internal" href="#qvariant">QVariant</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pyqt4-v4-5">PyQt4 v4.5</a><ul>
<li><a class="reference internal" href="#id1">QVariant</a></li>
<li><a class="reference internal" href="#pyrcc4-support-for-python-v3"><strong class="program">pyrcc4</strong> Support for Python v3</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="introduction.html"
                        title="previous chapter">Introduction</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="installation.html"
                        title="next chapter">Installing PyQt4</a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installing PyQt4"
             >next</a> |</li>
        <li class="right" >
          <a href="introduction.html" title="Introduction"
             >previous</a> |</li>
        <li><a href="index.html">PyQt 4.10.3 Reference Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2013 Riverbank Computing Limited.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>