I wan to creat window app for manage student OF CLASS
QComboBox not show, helping
My code is here
import PyQt5 import QtCore, QtGui
import PyQt5.QtGui import *
import PyQt5.QtWidgets import *
import PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("stsudent class")
self.setGeometry(-100, +100, 600, 400)
self.UiComponents()
self.setVisible(True)
def self.UiComponents():
self.combo_box = QComboBox(self)
self.combo_box.setGeometry(200, 150, 150, 30)
list_student = ["Richy", "bruce", "Ahmed", "Zoubobo"]
self.combo_box.addItems(list_student)
edit = QLineEdit(self)
self.combo_box.setLineEdit(edit)
App = QApplication(sys.argv)
window = Window()
app.exit(App.exec()
guys can you see this
>Solution :
Try this
So i changed QComboBox() to QComboBox(Self) –>to display it into the MainWindow show() on that will make it to
i changed self.setVisible(True) to –> self.show()
And it’s not really app.exit() it’s sys.exit(App.exec()) or sys.exit(App.exec())
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("class student")
self.setGeometry(100, 100, 600, 400)
self.UiComponents()
self.show()
def UiComponents(self):
self.combo_box = QComboBox(self)
self.combo_box.setGeometry(200, 150, 150, 30)
list_student = ["Richy", "bruce", "Ahmed", "Zoubobo"]
self.combo_box.addItems(list_student)
edit = QLineEdit(self)
self.combo_box.setLineEdit(edit)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())