Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76615 > unrolled thread
| Started by | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
|---|---|
| First post | 2014-08-20 00:32 +0200 |
| Last post | 2014-08-20 00:32 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2014-08-20 00:32 +0200
| From | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
|---|---|
| Date | 2014-08-20 00:32 +0200 |
| Subject | Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout |
| Message-ID | <mailman.13173.1408488242.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web