Page MenuHomePhabricator

[electrum] no need to pass parent to MyTreeWidget
ClosedPublic

Authored by PiRK on Jun 30 2023, 15:03.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC6b6700377247: [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.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable