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

PySide docs: Auto snippet converter turns "return" to "def"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • None
    • 6.3.1
    • Documentation
    • None
    • 9f72774579 (pyside/pyside-setup/dev) becb2b6b64 (pyside/pyside-setup/6.3) becb2b6b64 (pyside/tqtc-pyside-setup/6.3) 9f72774579 (pyside/tqtc-pyside-setup/dev) becb2b6b64 (pyside/pyside-setup/wip/6.3_pypy) c4817b8751 (pyside/tqtc-pyside-setup/6.2)

    Description

      Here's one example.

      Notice also that most "if" and "else" lines don't have colons, and the one that does is indented wrongly.

       

      Cpp snippet (from https://doc.qt.io/qt-6/qtwidgets-itemviews-simpletreemodel-example.html)

      QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
      {
          if (!hasIndex(row, column, parent))
              return QModelIndex();
      
          TreeItem *parentItem;
      
          if (!parent.isValid())
              parentItem = rootItem;
          else
              parentItem = static_cast<TreeItem*>(parent.internalPointer());
      
          TreeItem *childItem = parentItem->child(row);
          if (childItem)
              return createIndex(row, column, childItem);
          return QModelIndex();
      }
      

       

      Auto-converted Python snippet (from https://doc.qt.io/qtforpython/overviews/qtwidgets-itemviews-simpletreemodel-example.html)

      def index(self, int row, int column, QModelIndex parent):
      
          if (not hasIndex(row, column, parent))
              def QModelIndex():
          parentItem = TreeItem()
          if (not parent.isValid())
              parentItem = rootItem
      else:
              parentItem = TreeItem(parent.internalPointer())
          childItem = parentItem.child(row)
          if (childItem)
              def createIndex(row,column,childItem):
          def QModelIndex():
      

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              jksh Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: