A
A
arama922018-04-19 11:58:24
Python
arama92, 2018-04-19 11:58:24

PyQt5 another class function not working, why?

Help me please. There is a code and a form. The form has an empty QWidget (wid). It is necessary to fill wid from another class, so that all functions work,
here is the code:

import os
import sys
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUi

class Start(QMainWindow):
    def __init__(self):
        #super(Start, self).__init__()
        QMainWindow.__init__(self)
        loadUi("untitled.ui", self)
        Down(self.wid)

class Down(QWidget):
    def __init__(self, wid):
        super(Down, self).__init__()

        self.line = QLineEdit(self)                    
        self.line.setPlaceholderText("TEXT")  

        btn = QPushButton('Click')              

        vbox = QVBoxLayout(wid)                    
        vbox.addWidget(self.line)
        vbox.addWidget(btn)

        btn.clicked.connect(self.PreDownload)           



    def PreDownload(self):
         print("click")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = Start()
    mainWindow.show()
    sys.exit(app.exec_())

5ad859b889846039643664.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TriKrista, 2018-04-19
@arama92

try:

vbox = QVBoxLayout() 
//...
wid->setLayout(vbox)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question