How can i add a button and qlineedit here?



  • import sys
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    import mysql.connector
    from PyQt4.QtSql import *
    class Example(QWidget):

    def __init__(self): 
        super(Example, self).__init__() 
         
        self.initUI() 
         
    def initUI(self):        
        hbox = QHBoxLayout(self)  
        topleft = QFrame() 
        topleft.setFrameShape(QFrame.StyledPanel) 
        bottom = QFrame() 
        bottom.setFrameShape(QFrame.StyledPanel)
    
            
        splitter1 = QSplitter(Qt.Horizontal) 
        db = QSqlDatabase.addDatabase("QMYSQL")
    
        db.setHostName("localhost")
        db.setDatabaseName("incoming_mac")
        db.setUserName("root")
        db.setPassword("admingelo")
        db.open()
    
        projectModel = QSqlQueryModel()
        projectModel.setQuery("select * from incoming_mac_records",db)
    
        projectView = QTableView()
        projectView.setModel(projectModel)
        projectView.resizeColumnsToContents()
        projectView = QTableView()
        projectView.setModel(projectModel)
        projectView.resizeColumnsToContents()
        splitter1.addWidget(projectView)
        splitter1.setSizes([150,500]) 
        splitter2 = QSplitter(Qt.Vertical)
        splitter2.addWidget(splitter1)
        hbox.addWidget(splitter2)
        
        self.setLayout(hbox) 
        QApplication.setStyle(QStyleFactory.create('Cleanlooks')) 
         
        self.setGeometry(50, 50, 1200, 700) 
    
        self.setWindowTitle('QSplitter demo') 
        self.show() 
    

    def main():
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
    if name == 'main':
    main()


  • Moderators

    @Gelo What exactly is the problem?
    If you need a button then create one and add it the layout, same for line edit.
    And what do you mean with "here"? Where do you want to add them?



  • @jsulm Already figure it out thank you so much :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.