Sophie

Sophie

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

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>PyQt4 and Python v3 &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="PyQt4 and Qt v5" href="qt_v5.html" />
    <link rel="prev" title="Installing PyQt4" href="installation.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="qt_v5.html" title="PyQt4 and Qt v5"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installing PyQt4"
             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="pyqt4-and-python-v3">
<h1>PyQt4 and Python v3<a class="headerlink" href="#pyqt4-and-python-v3" title="Permalink to this headline">¶</a></h1>
<p>PyQt4 fully supports all versions of Python v3.  The default behaviour is
different in some areas to the default behaviour with Python v2.  These
incompatible differences were introduced in order to make PyQt4 more Pythonic.
However it is very easy to revert to the default Python v2 behaviour on a class
by class basis if required.  (See the section <a class="reference internal" href="incompatible_apis.html#ref-incompat-apis"><em>Selecting Incompatible APIs</em></a>.)</p>
<div class="section" id="qabstractspinbox">
<h2>QAbstractSpinBox<a class="headerlink" href="#qabstractspinbox" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QAbstractSpinBox.fixup(str input) -&gt; str
QAbstractSpinBox.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qchar">
<h2>QChar<a class="headerlink" href="#qchar" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QChar</span></tt> class is implemented as a mapped type that is automatically
converted to and from a Python string.</p>
</div>
<div class="section" id="qclipboard">
<h2>QClipboard<a class="headerlink" href="#qclipboard" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 call has a changed signature to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QClipboard.text(str subtype, QClipboard.Mode mode=QClipboard.Clipboard) -&gt; str, str</pre>
</div>
</div>
<div class="section" id="qdate">
<h2>QDate<a class="headerlink" href="#qdate" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QDate.__hash__()</span></tt> returns a hash of the string representation so that
two objects with the same date will have the same hash.</p>
<p>The default behaviour with Python v2 is to return the object&#8217;s <tt class="docutils literal"><span class="pre">id()</span></tt> so that
two objects with the same date will have different hashes.</p>
</div>
<div class="section" id="qdatetime">
<h2>QDateTime<a class="headerlink" href="#qdatetime" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QDateTime.__hash__()</span></tt> method returns a hash of the string representation
so that two objects with the same date and time will have the same hash.</p>
<p>The default behaviour with Python v2 is to return the object&#8217;s <tt class="docutils literal"><span class="pre">id()</span></tt> so that
two objects with the same date and time will have different hashes.</p>
</div>
<div class="section" id="qdatetimeedit">
<h2>QDateTimeEdit<a class="headerlink" href="#qdatetimeedit" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QDateTimeEdit.fixup(str input) -&gt; str
QDateTimeEdit.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qdoublespinbox">
<h2>QDoubleSpinBox<a class="headerlink" href="#qdoublespinbox" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QDoubleSpinBox.fixup(str input) -&gt; str
QDoubleSpinBox.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qdoublevalidator">
<h2>QDoubleValidator<a class="headerlink" href="#qdoublevalidator" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 call has a changed signature to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QDoubleValidator.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qfiledialog">
<h2>QFileDialog<a class="headerlink" href="#qfiledialog" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QFileDialog.getOpenFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -&gt; str
QFileDialog.getOpenFileNames(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -&gt; list(str)
QFileDialog.getSaveFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -&gt; str</pre>
</div>
<p>The static methods <tt class="docutils literal"><span class="pre">QFileDialog.getOpenFileNameAndFilter()</span></tt>,
<tt class="docutils literal"><span class="pre">QFileDialog.getOpenFileNamesAndFilter()</span></tt> and
<tt class="docutils literal"><span class="pre">QFileDialog.getSaveFileNameAndFilter()</span></tt> have been added which return a tuple
of the name(s) and the selected filter.  These can also be used with Python v2.</p>
</div>
<div class="section" id="qfontmetrics">
<h2>QFontMetrics<a class="headerlink" href="#qfontmetrics" title="Permalink to this headline">¶</a></h2>
<p>The methods <tt class="docutils literal"><span class="pre">QFontMetrics.widthChar()</span></tt> and
<tt class="docutils literal"><span class="pre">QFontMetrics.boundingRectChar()</span></tt> have been added which accept a Python
string of length one and call the C++ <tt class="docutils literal"><span class="pre">QFontMetrics::width()</span></tt> and
<tt class="docutils literal"><span class="pre">QFontMetrics::boundingRect()</span></tt> methods passing the character as a <tt class="docutils literal"><span class="pre">QChar</span></tt>
(rather than a single character <tt class="docutils literal"><span class="pre">QString</span></tt>).</p>
</div>
<div class="section" id="qfontmetricsf">
<h2>QFontMetricsF<a class="headerlink" href="#qfontmetricsf" title="Permalink to this headline">¶</a></h2>
<p>The methods <tt class="docutils literal"><span class="pre">QFontMetricsF.widthChar()</span></tt> and
<tt class="docutils literal"><span class="pre">QFontMetricsF.boundingRectChar()</span></tt> have been added which accept a Python
string of length one and call the C++ <tt class="docutils literal"><span class="pre">QFontMetricsF::width()</span></tt> and
<tt class="docutils literal"><span class="pre">QFontMetricsF::boundingRect()</span></tt> methods passing the character as a <tt class="docutils literal"><span class="pre">QChar</span></tt>
(rather than a single character <tt class="docutils literal"><span class="pre">QString</span></tt>).</p>
</div>
<div class="section" id="qintvalidator">
<h2>QIntValidator<a class="headerlink" href="#qintvalidator" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 call has a changed signature to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QIntValidator.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qlatin1char">
<h2>QLatin1Char<a class="headerlink" href="#qlatin1char" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QLatin1Char</span></tt> class is not implemented.</p>
</div>
<div class="section" id="qlatin1string">
<h2>QLatin1String<a class="headerlink" href="#qlatin1string" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QLatin1String</span></tt> class is not implemented.</p>
</div>
<div class="section" id="qpynullvariant">
<h2>QPyNullVariant<a class="headerlink" href="#qpynullvariant" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> class is used to represent a null <tt class="docutils literal"><span class="pre">QVariant</span></tt>.  It is
automatically converted to a C++ <tt class="docutils literal"><span class="pre">QVariant</span></tt> when required.</p>
<p>A null C++ <tt class="docutils literal"><span class="pre">QVariant</span></tt> is automatically converted to a <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt>
unless the type of the data in the <tt class="docutils literal"><span class="pre">QVariant</span></tt> itself supports the concept of
a null value (i.e. it has an <tt class="docutils literal"><span class="pre">isNull()</span></tt> method).  In this case a null C++
<tt class="docutils literal"><span class="pre">QVariant</span></tt> is converted to a null instance of the data type.  The exception
to this rule is that a C++ <tt class="docutils literal"><span class="pre">QVariant</span></tt> containing a null <tt class="docutils literal"><span class="pre">QString</span></tt> is always
converted to a <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt>.</p>
</div>
<div class="section" id="qregexpvalidator">
<h2>QRegExpValidator<a class="headerlink" href="#qregexpvalidator" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 call has a changed signature to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QRegExpValidator.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qsettings">
<h2>QSettings<a class="headerlink" href="#qsettings" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QSettings.value()</span></tt> method takes an optional <tt class="docutils literal"><span class="pre">type</span></tt> keyword argument
that specifies the type of the value to return.  It can either be a Python type
object or a string specifying the name of a C++ type.</p>
<p>Using this argument avoids potential portability problems where the type of a
value may not be as expected because the platform specific backend to
<tt class="docutils literal"><span class="pre">QSettings</span></tt> may not store the necessary type information.</p>
<p>The argument can also be used with Python v2.</p>
</div>
<div class="section" id="qspinbox">
<h2>QSpinBox<a class="headerlink" href="#qspinbox" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QSpinBox.fixup(str input) -&gt; str
QSpinBox.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qstring">
<h2>QString<a class="headerlink" href="#qstring" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QString</span></tt> class is implemented as a mapped type that is automatically
converted to and from a Python string.  In addition a <tt class="docutils literal"><span class="pre">None</span></tt> is converted to
a null <tt class="docutils literal"><span class="pre">QString</span></tt>.  However, a null <tt class="docutils literal"><span class="pre">QString</span></tt> is converted to an empty
Python string (and not <tt class="docutils literal"><span class="pre">None</span></tt>).  (This is because Qt often returns a null
<tt class="docutils literal"><span class="pre">QString</span></tt> when it should probably return an empty <tt class="docutils literal"><span class="pre">QString</span></tt>.)</p>
</div>
<div class="section" id="qstringlist">
<h2>QStringList<a class="headerlink" href="#qstringlist" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QStringList</span></tt> class is implemented as a mapped type that is
automatically converted to and from a Python list of strings.</p>
</div>
<div class="section" id="qstringmatcher">
<h2>QStringMatcher<a class="headerlink" href="#qstringmatcher" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QStringMatcher</span></tt> class is not implemented.</p>
</div>
<div class="section" id="qstringref">
<h2>QStringRef<a class="headerlink" href="#qstringref" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QStringRef</span></tt> class is implemented as a mapped type that is automatically
converted to and from a Python string.</p>
</div>
<div class="section" id="qtextdecoder">
<h2>QTextDecoder<a class="headerlink" href="#qtextdecoder" title="Permalink to this headline">¶</a></h2>
<p>The following C++ call is not wrapped because it expects <tt class="docutils literal"><span class="pre">QString</span></tt> to be
mutable:</p>
<div class="highlight-python"><pre>void toUnicode(QString *target, const char *chars, int len)</pre>
</div>
</div>
<div class="section" id="qtextstream">
<h2>QTextStream<a class="headerlink" href="#qtextstream" title="Permalink to this headline">¶</a></h2>
<p>The C++ functions <tt class="docutils literal"><span class="pre">bin()</span></tt>, <tt class="docutils literal"><span class="pre">hex()</span></tt> and <tt class="docutils literal"><span class="pre">oct()</span></tt> are named <tt class="docutils literal"><span class="pre">bin_()</span></tt>,
<tt class="docutils literal"><span class="pre">hex_()</span></tt> and <tt class="docutils literal"><span class="pre">oct_()</span></tt> respectively in Python.  This allows the import
style <tt class="docutils literal"><span class="pre">from</span> <span class="pre">PyQt4.QtCore</span> <span class="pre">import</span> <span class="pre">*</span></tt> to be used without them clashing with the
Python built-in functions with the same names.</p>
<p>The following C++ calls are not wrapped because they expect <tt class="docutils literal"><span class="pre">QString</span></tt> to be
mutable:</p>
<div class="highlight-python"><pre>QTextStream(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
void setString(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
QString *string()
QTextStream &amp;operator&gt;&gt;(QChar &amp;c)
QTextStream &amp;operator&gt;&gt;(QString &amp;s)</pre>
</div>
</div>
<div class="section" id="qtime">
<h2>QTime<a class="headerlink" href="#qtime" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QTime.__hash__()</span></tt> returns a hash of the string representation so that
two objects with the same time will have the same hash.</p>
<p>The default behaviour with Python v2 is to return the object&#8217;s <tt class="docutils literal"><span class="pre">id()</span></tt> so that
two objects with the same time will have different hashes.</p>
</div>
<div class="section" id="qurl">
<h2>QUrl<a class="headerlink" href="#qurl" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QUrl.__hash__()</span></tt> method returns a hash of the string representation so
that two objects with the same URL will have the same hash.</p>
<p>The default behaviour with Python v2 is to return the object&#8217;s <tt class="docutils literal"><span class="pre">id()</span></tt> so that
two objects with the same URL will have different hashes.</p>
</div>
<div class="section" id="qvalidator">
<h2>QValidator<a class="headerlink" href="#qvalidator" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 calls have changed signatures to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QValidator.fixup(str input) -&gt; str
QValidator.validate(str input, int pos) -&gt; QValidator.State, str, int</pre>
</div>
</div>
<div class="section" id="qvariant">
<h2>QVariant<a class="headerlink" href="#qvariant" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">QVariant</span></tt> class is implemented as a mapped type.  Any Python object can
be passed when a <tt class="docutils literal"><span class="pre">QVariant</span></tt> instance is expected.  When Qt returns a
<tt class="docutils literal"><span class="pre">QVariant</span></tt> then it will automatically be converted to the original Python
object or an equivalent.</p>
<p><tt class="docutils literal"><span class="pre">None</span></tt> is interpreted as an invalid <tt class="docutils literal"><span class="pre">QVariant</span></tt> and vice versa.</p>
<p>The <tt class="docutils literal"><span class="pre">QPyNullVariant</span></tt> class is used to represent a null <tt class="docutils literal"><span class="pre">QVariant</span></tt>.</p>
</div>
<div class="section" id="qwebpage">
<h2>QWebPage<a class="headerlink" href="#qwebpage" title="Permalink to this headline">¶</a></h2>
<p>The following PyQt4 call has a changed signature to avoid the need for mutable
strings:</p>
<div class="highlight-python"><pre>QWebPage.javaScriptPrompt(QWebFrame originatingFrame, str msg, str defaultValue) -&gt; bool, str</pre>
</div>
</div>
<div class="section" id="qxmlstreamwriter">
<h2>QXmlStreamWriter<a class="headerlink" href="#qxmlstreamwriter" title="Permalink to this headline">¶</a></h2>
<p>The following C++ call is not wrapped because it expects <tt class="docutils literal"><span class="pre">QString</span></tt> to be
mutable:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">QXmlStreamWriter</span><span class="p">(</span><span class="n">QString</span> <span class="o">*</span><span class="n">string</span><span class="p">)</span>
</pre></div>
</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="#">PyQt4 and Python v3</a><ul>
<li><a class="reference internal" href="#qabstractspinbox">QAbstractSpinBox</a></li>
<li><a class="reference internal" href="#qchar">QChar</a></li>
<li><a class="reference internal" href="#qclipboard">QClipboard</a></li>
<li><a class="reference internal" href="#qdate">QDate</a></li>
<li><a class="reference internal" href="#qdatetime">QDateTime</a></li>
<li><a class="reference internal" href="#qdatetimeedit">QDateTimeEdit</a></li>
<li><a class="reference internal" href="#qdoublespinbox">QDoubleSpinBox</a></li>
<li><a class="reference internal" href="#qdoublevalidator">QDoubleValidator</a></li>
<li><a class="reference internal" href="#qfiledialog">QFileDialog</a></li>
<li><a class="reference internal" href="#qfontmetrics">QFontMetrics</a></li>
<li><a class="reference internal" href="#qfontmetricsf">QFontMetricsF</a></li>
<li><a class="reference internal" href="#qintvalidator">QIntValidator</a></li>
<li><a class="reference internal" href="#qlatin1char">QLatin1Char</a></li>
<li><a class="reference internal" href="#qlatin1string">QLatin1String</a></li>
<li><a class="reference internal" href="#qpynullvariant">QPyNullVariant</a></li>
<li><a class="reference internal" href="#qregexpvalidator">QRegExpValidator</a></li>
<li><a class="reference internal" href="#qsettings">QSettings</a></li>
<li><a class="reference internal" href="#qspinbox">QSpinBox</a></li>
<li><a class="reference internal" href="#qstring">QString</a></li>
<li><a class="reference internal" href="#qstringlist">QStringList</a></li>
<li><a class="reference internal" href="#qstringmatcher">QStringMatcher</a></li>
<li><a class="reference internal" href="#qstringref">QStringRef</a></li>
<li><a class="reference internal" href="#qtextdecoder">QTextDecoder</a></li>
<li><a class="reference internal" href="#qtextstream">QTextStream</a></li>
<li><a class="reference internal" href="#qtime">QTime</a></li>
<li><a class="reference internal" href="#qurl">QUrl</a></li>
<li><a class="reference internal" href="#qvalidator">QValidator</a></li>
<li><a class="reference internal" href="#qvariant">QVariant</a></li>
<li><a class="reference internal" href="#qwebpage">QWebPage</a></li>
<li><a class="reference internal" href="#qxmlstreamwriter">QXmlStreamWriter</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="installation.html"
                        title="previous chapter">Installing PyQt4</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="qt_v5.html"
                        title="next chapter">PyQt4 and Qt v5</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="qt_v5.html" title="PyQt4 and Qt v5"
             >next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installing PyQt4"
             >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>