Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QGridLayout in PyQt5

QGridLayout in PyQt5

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 301 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DiGol
    wrote on last edited by
    #1

    I can't figure out why when I run the code the button(self.ui.btn) disappears. But without self.layout() it remains.

    from PyQt5.QtWidgets import QWidget, QApplication, QGridLayout
    from PyQt5 import uic
    import sys
    
    class App(QWidget):
        def __init__(self):
            super().__init__()
            self.design()
            self.layout()
        def design(self):
            self.ui = uic.loadUi('form.ui')
            self.ui.show()
        def layout(self):
            self.lay = QGridLayout()
            self.lay.setSpacing(10)
            self.lay.addWidget(self.ui.btn, 0, 1)
            self.setLayout(self.lay)
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = App()
        sys.exit(app.exec_())
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      Axel-Erfurt
      wrote on last edited by
      #2

      Whats the content of form.ui ?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved