0

QGIS V-3.4.5, Python 3.7.0

from qgis.gui import *
from qgis.core import *

import sip
sip.setapi('QString', 2)

from PyQt5.QtCore import * # QSettings, QTranslator, qVersion, QCoreApplication

from PyQt5.QtGui import * #QIcon
from PyQt5.QtWidgets import * #QAction

from PyQt5.QtXml import QDomDocument

import os.path
import os

...

 actionSelect = QAction( QString("Select"), self)

             NameError: name 'QString' is not defined

NameError: name 'QString' is not defined

WHY???

closed as off-topic by underdark Feb 28 at 19:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    what is that sip.setapi line supposed to do? – Spacedman Feb 28 at 18:14
1

There's no need for it - just use a python 3 string.

See for example discussion on the internet such as: http://python.6.x6.nabble.com/PyQt5-and-QString-td5043297.html

 actionSelect = QAction("Select", self)

I suppose if you are converting a bunch of code that uses QString() you could define:

def QString(x):
  return x

and remove any imports of Qt's QString.

  • Thanks! Works as actionSelect = QAction("Select") – Bek7 Feb 28 at 18:54

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