Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1915

suffixIndex gets dropped for QVersionNumber

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • Some future version
    • 6.3.0
    • PySide
    • None

    Description

      The C++ signature of QVersionNumber::fromString() is:

      QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex = nullptr)
      

      where suffixIndex is used as an out-argument. There are other occurences of this in Qt, e.g. QFileDialog::getSaveFileName:

      QString QFileDialog::getSaveFileName(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = nullptr, QFileDialog::Options options = Options())
      

      where selectedFilter is used to return the file type filter the user selected in the dialog.

      For that one, PySide6 actually handles this in the same way as PyQt does, by returning a tuple instead:

      <modify-argument index="return">
        <replace-type modified-type="(fileName, selectedFilter)"/>
      </modify-argument>
      // ...
      <inject-code class="target" position="end" file="../glue/qtwidgets.cpp" snippet="qfiledialog-return" />
      

      But contrary to PyQt, it does not do the same thing for QVersionNumber, thus rendering parts of its functionality unusable:

      >>> from PyQt6.QtCore import QVersionNumber
      >>> s = "1.5.0.post1"
      >>> v, i = QVersionNumber.fromString(s)
      >>> s[i:]
      '.post1'
      >>> v
      <PyQt6.QtCore.QVersionNumber object at 0x7ff4392c97e0>
      

      but:

      >>> from PySide6.QtCore import QVersionNumber
      >>> s = "1.5.0.post1"
      >>> v = QVersionNumber.fromString(s)
      >>> v
      <1.5.0 at 0x7efc51e22040>
      

      because PySide6 simply drops the argument entirely:

      <modify-function signature="fromString(const QString &amp;,int*)">
        <modify-argument index="2">
          <remove-argument/>
        </modify-argument>
      </modify-function>
      

      And there seems no good way to get it back before PySide7 now, because doing so
      is backwards-incompatible.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            the compiler Florian Bruhin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes