Skip to main content
added 1674 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Try to pass the third parameter as string which refers property name, filePath here.

self.wizardPage.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)

Here is a working example in QGIS Python Editor:

from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *


class Wizard(QWizard):
    def __init__(self, parent=None):
        super(Wizard, self).__init__(parent)
        self.addPage(Page1(self))
        self.addPage(Page2(self))
        self.setWindowTitle("Test")


class Page1(QWizardPage):
    def __init__(self, parent=None):
        super(Page1, self).__init__(parent)

        self.projPath = QgsFileWidget(self)
        self.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)
        self.projPath.fileChanged.connect(self.file_changed)
        
        layout = QVBoxLayout()
        layout.addWidget(self.projPath)
        self.setLayout(layout)
        
    def file_changed(self):
        self.setField("projPath", self.projPath.filePath())
    
    def isComplete(self): # Re-implementation of isComplete
        return bool(self.projPath.filePath())


class Page2(QWizardPage):
    def __init__(self, parent=None):
        super(Page2, self).__init__(parent)
        self.label = QLabel()
        layout = QVBoxLayout()
        layout.addWidget(self.label)
        self.setLayout(layout)
    
    def initializePage(self):
        path = self.field("projPath")
        self.label.setText(f"Path: '{path}'")
        

wizard = Wizard()
wizard.show()

enter image description here

Try to pass the third parameter as string which refers property name, filePath here.

self.wizardPage.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)

Try to pass the third parameter as string which refers property name, filePath here.

self.wizardPage.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)

Here is a working example in QGIS Python Editor:

from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *


class Wizard(QWizard):
    def __init__(self, parent=None):
        super(Wizard, self).__init__(parent)
        self.addPage(Page1(self))
        self.addPage(Page2(self))
        self.setWindowTitle("Test")


class Page1(QWizardPage):
    def __init__(self, parent=None):
        super(Page1, self).__init__(parent)

        self.projPath = QgsFileWidget(self)
        self.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)
        self.projPath.fileChanged.connect(self.file_changed)
        
        layout = QVBoxLayout()
        layout.addWidget(self.projPath)
        self.setLayout(layout)
        
    def file_changed(self):
        self.setField("projPath", self.projPath.filePath())
    
    def isComplete(self): # Re-implementation of isComplete
        return bool(self.projPath.filePath())


class Page2(QWizardPage):
    def __init__(self, parent=None):
        super(Page2, self).__init__(parent)
        self.label = QLabel()
        layout = QVBoxLayout()
        layout.addWidget(self.label)
        self.setLayout(layout)
    
    def initializePage(self):
        path = self.field("projPath")
        self.label.setText(f"Path: '{path}'")
        

wizard = Wizard()
wizard.show()

enter image description here

Post Undeleted by Kadir Şahbaz
Post Deleted by Kadir Şahbaz
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Try to pass the third parameter as string which refers property name, filePath here.

self.wizardPage.registerField('projPath*', self.projPath, 'filePath', self.projPath.fileChanged)