Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Design crushing to corner and failing to layout PyQT5
Forum Updated to NodeBB v4.3 + New Features

Design crushing to corner and failing to layout PyQT5

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 647 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    crabcrabcam
    wrote on last edited by
    #1

    I'm kinda new to this so I'm basically just copy pasting the stuff from tutorials I've done to make it work.

    I've made a designer.ui file with QtDesigner and now I've exported it to Python code. If I use the -x command then run the design Python it works fine, but if I import it to another file (so I can make connections) then it all crushes down to 1 place rather than sticking to the grid layout base.

    If I launch my Main.py file (not designer code) then I get the error QLayout: Attempting to add QLayout "" to MainWindow "MainWindow", which already has a layout but I don't see where I'm adding a layout within my Main code...

    My code is: https://gist.github.com/crabcrabcam/3a6a9e847791117616d18ada0895f868

    Thanks for any help :) If you need some more stuff just ask.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      self.gridLayout = QtWidgets.QGridLayout(MainWindow) in your MainDes.py triggers the message. Passing a widget as parent of the layout will make the layout applied to that widget. QMainWindow already has the layout that implements all the features like dock handling etc.

      On a side note, why QtWidgets.QWidget.__init__(self, parent) and not QtWidgets.QMainWindow.__init__(self, parent) in Main.py ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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