HomePhabricator

[electrum] no need to pass parent to MyTreeWidget

Description

[electrum] no need to pass parent to MyTreeWidget

Summary:
MyTreeWidget does nothing with its parent except forward it to QTreeWidget.__init__. In practice, explicitely specifying the parent widget is not necessary because all of these widgets are added to a some other widget's QLayout , which automatically takes care of adding the parent hierarchy.

See https://riptutorial.com/qt/topic/9380/about-using-layouts--widget-parenting:

When you use a layout, you do not need to pass a parent when constructing the child widgets. The layout will automatically reparent the widgets (using QWidget::setParent()) so that they are children of the widget on which the layout is installed.

This change will make my next commit a bit simpler, when I start using multiple inheritance in MyTreeWidget to extract some of its functionality to mixin classes. It means that we will need to worry only about the parameters of one parent class, as QTreeWidget.__init__ no longer takes any parameters.

Related to T3206 (switching from a tree widget to a tree view for the transaction history, address list and coins list).

Depends on D14168

Test Plan: run the application python electrum/electrum-abc, make sure all tabs are displayed correctly with all widgets (transaction history, address lists, utxo lists...) visible. If a widget was not properly parented via a layout, it would be invisible or floating outside the main window.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14168

Details

Provenance
PiRKAuthored on Jun 30 2023, 13:18
PiRKPushed on Jul 3 2023, 09:50
Reviewer
Restricted Project
Differential Revision
D14168: [electrum] no need to pass parent to MyTreeWidget
Parents
rABC1160f80bb888: [electrum] move-only: extract MyTreeWidget and related code to its own module
Branches
Unknown
Tags
Unknown