Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

pyqt5: Mainwindow not showing Combobox

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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())

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading