Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76610 > unrolled thread

PyQt4 - Issue with deleting a QWidget from a QGridLayout

Started by"Alex Murray" <Alex.Murray@gmx.ch>
First post2014-08-20 00:11 +0200
Last post2014-08-20 17:27 +0200
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  PyQt4 - Issue with deleting a QWidget from a QGridLayout "Alex Murray" <Alex.Murray@gmx.ch> - 2014-08-20 00:11 +0200
    Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout alister <alister.nospam.ware@ntlworld.com> - 2014-08-20 09:33 +0000
      Re: Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout "Alex Murray" <Alex.Murray@gmx.ch> - 2014-08-20 16:22 +0200
      Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2014-08-20 17:27 +0200

#76610 — PyQt4 - Issue with deleting a QWidget from a QGridLayout

From"Alex Murray" <Alex.Murray@gmx.ch>
Date2014-08-20 00:11 +0200
SubjectPyQt4 - Issue with deleting a QWidget from a QGridLayout
Message-ID<mailman.13169.1408486595.18130.python-list@python.org>
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi,</div>

<div>&nbsp;</div>

<div>I&#39;ve discovered some very strange behaviour when trying to delete a QWidget from a QGridLayout. The following code demonstrates this behaviour:</div>

<div>&nbsp;</div>

<div>&gt;&gt;&gt; from PyQt4 import QtGui</div>

<div>&gt;&gt;&gt; import sys</div>

<div>&gt;&gt;&gt; app = QtGui.QApplication(sys.argv)</div>

<div>&gt;&gt;&gt; grid_layout = QtGui.QGridLayout()<br/>
&gt;&gt;&gt; grid_layout.addWidget(QtGui.QWidget())<br/>
&gt;&gt;&gt; item = self.grid_layout.takeAt(0)<br/>
&gt;&gt;&gt; item.deleteLater()</div>

<div>Traceback (most recent call last):<br/>
&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br/>
AttributeError: &#39;QWidgetItem&#39; object has no attribute &#39;deleteLater&#39;</div>

<div>&nbsp;</div>

<div>This makes no sense to me whatsoever. Firstly, why is it returning a QWidgetItem when I inserted a QWidget to begin with? Secondly, every Qt object derives from QObject, and deleteLater() is a method of QObject, so that method should exist. Additional info:</div>

<div>
<div>Python 2.7.6 (default, Mar 22 2014, 22:59:56)<br/>
[GCC 4.8.2] on linux2</div>

<div>using PyQt4</div>
</div></div></body></html>

[toc] | [next] | [standalone]


#76650

Fromalister <alister.nospam.ware@ntlworld.com>
Date2014-08-20 09:33 +0000
Message-ID<hXZIv.18639$ck2.6303@fx17.am4>
In reply to#76610
On Wed, 20 Aug 2014 00:11:24 +0200, Alex Murray wrote:

> <html><head></head><body><div style="font-family: Verdana;font-size:
> 12.0px;"><div>Hi,</div>
> 
> <div>&nbsp;</div>
> 
> <div>I&#39;ve discovered some very strange behaviour when trying to
> delete a QWidget from a QGridLayout. The following code demonstrates
> this behaviour:</div>
> 
> <div>&nbsp;</div>
> 
> <div>&gt;&gt;&gt; from PyQt4 import QtGui</div>
> 
> <div>&gt;&gt;&gt; import sys</div>
> 
> <div>&gt;&gt;&gt; app = QtGui.QApplication(sys.argv)</div>
> 
> <div>&gt;&gt;&gt; grid_layout = QtGui.QGridLayout()<br/>
> &gt;&gt;&gt; grid_layout.addWidget(QtGui.QWidget())<br/>
> &gt;&gt;&gt; item = self.grid_layout.takeAt(0)<br/>
> &gt;&gt;&gt; item.deleteLater()</div>
> 
> <div>Traceback (most recent call last):<br/>
> &nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br/>
> AttributeError: &#39;QWidgetItem&#39; object has no attribute
> &#39;deleteLater&#39;</div>
> 
> <div>&nbsp;</div>
> 
> <div>This makes no sense to me whatsoever. Firstly, why is it returning
> a QWidgetItem when I inserted a QWidget to begin with? Secondly, every
> Qt object derives from QObject, and deleteLater() is a method of
> QObject, so that method should exist. Additional info:</div>
> 
> <div>
> <div>Python 2.7.6 (default, Mar 22 2014, 22:59:56)<br/>
> [GCC 4.8.2] on linux2</div>
> 
> <div>using PyQt4</div>
> </div></div></body></html>

Please do not post in HTML it makes everything an unreadable mess
(I have left you original post above so you can see what I mean.)



-- 
<dark> "Yes, your honour, I have RSA encryption code tattood on my
        penis.  Shall I show the jury?"

[toc] | [prev] | [next] | [standalone]


#76666

From"Alex Murray" <Alex.Murray@gmx.ch>
Date2014-08-20 16:22 +0200
Message-ID<mailman.13211.1408545797.18130.python-list@python.org>
In reply to#76650
> Please do not post in HTML it makes everything an unreadable mess
> (I have left you original post above so you can see what I mean.)

Sorry, here's the original e-mail in plain text:

Hi,

I've discovered some very strange behaviour when trying to
delete a QWidget from a QGridLayout. The following code demonstrates
this behaviour:

>>> from PyQt4 import QtGui
>>> import sys
>>> app = QtGui.QApplication(sys.argv)
>>> grid_layout = QtGui.QGridLayout()
>>> grid_layout.addWidget(QtGui.QWidget())
>>> item = grid_layout.takeAt(0)
>>> item.deleteLater()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'QWidgetItem' object has no attribute 'deleteLater'

This makes no sense to me whatsoever. Firstly, why is it returning
a QWidgetItem when I inserted a QWidget to begin with? Secondly, every
Qt object derives from QObject, and deleteLater() is a method of
QObject, so that method should exist. Additional info:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2

[toc] | [prev] | [next] | [standalone]


#76670

FromVincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
Date2014-08-20 17:27 +0200
Message-ID<mailman.13213.1408548467.18130.python-list@python.org>
In reply to#76650
Le 20/08/2014 16:22, Alex Murray a écrit :
>> Please do not post in HTML it makes everything an unreadable mess
>> (I have left you original post above so you can see what I mean.)
> Sorry, here's the original e-mail in plain text:
>
> Hi,
>
> I've discovered some very strange behaviour when trying to
> delete a QWidget from a QGridLayout. The following code demonstrates
> this behaviour:
>
>>>> from PyQt4 import QtGui
>>>> import sys
>>>> app = QtGui.QApplication(sys.argv)
>>>> grid_layout = QtGui.QGridLayout()
>>>> grid_layout.addWidget(QtGui.QWidget())
>>>> item = grid_layout.takeAt(0)
>>>> item.deleteLater()
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> AttributeError: 'QWidgetItem' object has no attribute 'deleteLater'
>
> This makes no sense to me whatsoever. Firstly, why is it returning
> a QWidgetItem when I inserted a QWidget to begin with? Secondly, every
> Qt object derives from QObject, and deleteLater() is a method of
> QObject, so that method should exist. Additional info:
>
> Python 2.7.6 (default, Mar 22 2014, 22:59:56)
> [GCC 4.8.2] on linux2
Not exactly, QLayoutItem or QSpacerItem doesn't inherits of QObject.
As I've sayed in my precedent post, you must use 
item.widget().deleteLater().

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web