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


Groups > comp.lang.python > #76615

Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <vincent.vande.vyvre@telenet.be>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.03; 'attribute': 0.07; 'see:': 0.07; 'sys': 0.07; 'inserted': 0.09; 'instance.': 0.09; 'python': 0.11; 'exist.': 0.16; 'from:name:vincent vande vyvre': 0.16; 'himself.': 0.16; 'received:195.130': 0.16; 'received:195.130.137': 0.16; 'received :telenet-ops.be': 0.16; 'with?': 0.16; '\xe9crit': 0.16; 'app': 0.19; 'trying': 0.19; 'alex': 0.19; 'subject:Issue': 0.19; 'widget': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'skip:g 30': 0.30; 'code': 0.31; "skip:' 10": 0.31; '"",': 0.31; 'skip:q 20': 0.31; 'file': 0.32; '(most': 0.33; 'sense': 0.34; 'subject:from': 0.34; 'subject:with': 0.35; 'returning': 0.36; 'method': 0.36; 'hi,': 0.36; 'should': 0.36; 'to:addr:python- list': 0.38; 'recent': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'charset:windows-1252': 0.65; 'header:Reply-To:1': 0.67; 'mar': 0.68; 'reply-to:no real name:2**0': 0.71; 'discovered': 0.83; '2014,': 0.84; 'demonstrates': 0.84
Date Wed, 20 Aug 2014 00:32:44 +0200
From Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version 1.0
To python-list@python.org
Subject Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout
References <trinity-ba38a980-24bc-4114-a9d2-3b644b0fc371-1408486284525@3capp-gmx-bs05>
In-Reply-To <trinity-ba38a980-24bc-4114-a9d2-3b644b0fc371-1408486284525@3capp-gmx-bs05>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To vincent.vandevyvre@oqapy.eu
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13173.1408488242.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408488242 news.xs4all.nl 2850 [2001:888:2000:d::a6]:39423
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76615

Show key headers only | View raw


Le 20/08/2014 00:11, Alex Murray a écrit :
> 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 = self.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
> using PyQt4
>
>
QLayout.takeAt() returns a QWidgetItem not the instance of the widget 
himself.

See: http://pyqt.sourceforge.net/Docs/PyQt4/qlayout.html#takeAt

You must use item.widget() to retrieve your widget instance.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2014-08-20 00:32 +0200

csiph-web