-2

目前 Pyqt 存在问题,因为我们需要删除我们找不到的布局内容。

这基本上是我们所拥有的:

<Layout1>
  <Widget1>
    <Layout2>
      <Widget2>
        ...

我们一开始没有 Layout2,也不想做

Widget1 = Widget2

所以我们添加了一个布局(Layout2),但是当我们试图改变 Widget1 的内容时,我们有一个自己重新设计的类(看起来像 Qtdesigner 生成器),带有一个 setupUi 方法和 Widget1 的参数:

class ... :
  def setupUi(self, Widget1):
    #Creating Layout2 with Widget1 as parent
    #Creating Widget2 with Widget1 as parent
    #Adding Widget2 to Layout2
    ...

在将Widget1的内容添加到Widget1时,我们就没有问题了。然后我们需要更改内容,因此我们需要删除 Widget1 中的所有内容(好吧,我们认为删除是解决方案)。

所以问题来了:删除所有内容时,我们无法删除 2 个布局之间的神秘链接。所以我们被这一切搞砸了,我们现在完全迷路了。我们一直在尝试使用父/子方法,但我们甚至无法得到我们想要的......

正如我所说:

我怎样才能简单地删除所有 Widget1 内容,实际上如何删除 Layout2?

4

1 回答 1

0

We worked it out as I missed a line in the code of my collegue.

He was adding layout 2 to layout 1 and that was the problem.

So Layout just needs the children to be added to it.

于 2013-02-20T07:46:14.457 回答