2

What does this error message mean:

AttributeError: 'QLineEdit' object has no attribute 'toPlainText'

I get this every time I try to run the QPackage Plugin.

2 Answers 2

2

If you refer to the Qt documentation (QLineEdit - Qt) the QLineEdit widget has no toPlainText() function.

This is a method that can be used with the QTextEdit widget (QTextEdit - Qt).

1

You can fix the QPackage plugin and make it work like a charm (great package!) by opening the package file, QPackage_dialog.py, for me it was here:

C:\Users\myname\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\QPackage

Two simple changes will make this file/QPackage compatible with the new QGIS version: (make sure to restart QGIS after changing and saving the file)

  1. Add import shutil to the import statement on top
  2. Change self._repertoire.toPlainText() into self._repertoire.text() around lines 134 to 141 (three times), as follows:
    elif layer.type() == QgsMapLayer.RasterLayer:
        layer.__class__ = QgsRasterLayer
        if(self._repertoire.text() != ""):
            if os.name == 'nt':
                shutil.copy2(layer.publicSource(), self._repertoire.text() + "\\" + os.path.basename(layer.publicSource()))
            else:
                shutil.copy2(layer.publicSource(), self._repertoire.text() + "/" + os.path.basename(layer.publicSource()))
2
  • I have a similar problem on Windows but not on Mac with the toMarkdown() method. Is there an equivalent?
    – wingnut
    Apr 17, 2021 at 16:10
  • This addresses the current error. But "projection" is not defined for raster layers, resulting in an error a few lines down (near 154). Defining the projection just leads to failures further down, wish I had the skillz: QPackage_dialog.py, line 181, in copierCouches DOMTree = Parse(fichierprojet) minidom.py, line 1958, in parse return expatbuilder.parse(file) expatbuilder.py, line 911, in parse result = builder.parseFile(fp) expatbuilder.py, line 207, in parseFile parser.Parse(buffer, 0) xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 2 Nov 1, 2021 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.