lmotta / mapswipetool_plugin

GNU General Public License v2.0
19 stars 10 forks source link

TypeError: arguments did not match any overloaded call: QLine(): too many arguments #18

Open florianneukirchen opened 10 months ago

florianneukirchen commented 10 months ago

1) Open 2 Rasterlayers in QGIS 3.32.3-Lima 2) Click on the Plugin Icon in the toolbar (The mousepointer changes) 3) Click or click-drag in the map view

The plugin crashes instantly with:

An error has occurred while executing Python code:

TypeError: arguments did not match any overloaded call: QLine(): too many arguments QLine(QPoint, QPoint): argument 1 has unexpected type 'int' QLine(int, int, int, int): argument 4 has unexpected type 'float' QLine(QLine): argument 1 has unexpected type 'int' Traceback (most recent call last): File "/home/riannek/.local/share/QGIS/QGIS3/profiles/default/python/plugins/mapswipetool_plugin/swipemap.py", line 62, in paint line = QLine( w-1,0,w-1,h-1 ) TypeError: arguments did not match any overloaded call: QLine(): too many arguments QLine(QPoint, QPoint): argument 1 has unexpected type 'int' QLine(int, int, int, int): argument 4 has unexpected type 'float' QLine(QLine): argument 1 has unexpected type 'int'

Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] QGIS version: 3.32.3-Lima Lima, 67d46100b5

Python Path: /usr/share/qgis/python /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python/plugins /usr/share/qgis/python/plugins /usr/lib/python310.zip /usr/lib/python3.10 /usr/lib/python3.10/lib-dynload /usr/local/lib/python3.10/dist-packages /usr/lib/python3/dist-packages /usr/lib/python3.10/dist-packages /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python/plugins/vrtbuilderplugin /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python/plugins/vrtbuilderplugin/vrtbuilder /home/riannek/.local/share/QGIS/QGIS3/profiles/default/python/plugins/shapetools/ext-libs /home/riannek/BHT Semester 1/gis modellierung/aufgabe 2

Heryx commented 3 months ago

I have the same problem:

TypeError

arguments did not match any overloaded call:

  QLine(): too many arguments
  QLine(pt1_: QPoint, pt2_: QPoint): argument 1 has unexpected type 'int'
  QLine(x1pos: int, y1pos: int, x2pos: int, y2pos: int): argument 4 has unexpected type 'float'
  QLine(a0: QLine): argument 1 has unexpected type 'int'
Heryx commented 3 months ago

I solved it by modifying this function

    def paint(self, painter, *args): # NEED *args for   WINDOWS!
        if len(self.layers) == 0 or self.length == -1:
            return

        if self.isVertical:
            h = int(self.boundingRect().height() - 2)
            w = int(self.length)
            line = QLine(w - 1, 0, w - 1, h - 1)
        else:
            h = int(self.boundingRect().height() - self.length)
            w = int(self.boundingRect().width() - 2)
            line = QLine(0, h - 1, w - 1, h - 1)

        image = self.image.copy(0, 0, w, h)
        painter.drawImage(QRect(0, 0, w, h), image)
        painter.drawLine(line)
    def setLength(self, x, y):
        y = int(self.boundingRect().height() - y)
        self.length = int(x) if self.isVertical else int(y)
        self.update()

I forked the plugin and fixed the code, you can download it here if you want:

Heryx/mapswipetool_plugin

Here is the repo Git Repo Best wishes