[[+content_image]]
W
W
w0lkolak2020-08-27 07:40:16
PyQt
w0lkolak, 2020-08-27 07:40:16

PyQt5. How to completely destroy a tab and its contents?

There is a qtabwidget.
There is a list of the form a[['file1', None]['file2', None]...] When the button is clicked, the list elements are dynamically filled and tabs are added . I included the closable and movable options. How to throw out the tab and the widget contained in it on the tabCloseRequsted event? I used to remove widgeta
а[i][1] = QTextEdit()tabwidget.addtab(a[i][1], a[i][0])

a[i][1] = None
self.widget(i) = None

, where i is inherited from the tabCloseRequsted event. However, i is just the current location of the tab in the layout. If the tabs were moved or deleted, then I will reset the wrong a[i][1]. ((
If I drop the list, then I won't be able to keep track of which tab names already exist
...
if a[i][1] not None:
...


Please tell me how to remove the correct a[i][1] when closing the tab.
Well, or how to dynamically track which tab names are currently in use without creating my list

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question