Answer the question
In order to leave comments, you need to log in
How to write user selected QComboBox value in PyQt5?
import sys
import os
from PySide2.QtWidgets import QApplication, QWidget
from PySide2.QtCore import QFile
from PySide2.QtUiTools import QUiLoader
class Constructor(QWidget):
def __init__(self):
super(Constructor, self).__init__()
self.load_ui()
def load_ui(self):
loader = QUiLoader()
path = os.path.join(os.path.dirname(__file__), "form.ui")
ui_file = QFile(path)
ui_file.open(QFile.ReadOnly)
loader.load(ui_file, self)
ui_file.close()
if __name__ == "__main__":
app = QApplication([])
widget = Constructor()
widget.setWindowTitle("Constructor")
widget.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.uic import loadUi
class m(QWidget):
def __init__(self):
self.app = QApplication([])
super().__init__()
loadUi('form.ui', self)
self.CBsettings.currentIndexChanged.connect(self.change)
self.show()
self.app.exec()
def change(self, index):
print(self.CBsettings.itemText(index))
m()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question