Skip to content

Commit 1e31eca

Browse files
committed
qt: Stop the effect of hidden widgets on the size of QStackedWidget
Layouts of the hidden widgets, those are children of QStackedWidget, could prevent to adjust the size of the parent widget in the WalletFrame widget.
1 parent f0d0479 commit 1e31eca

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/qt/walletframe.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,23 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
106106
{
107107
if (mapWalletViews.count(wallet_model) == 0) return;
108108

109+
// Stop the effect of hidden widgets on the size hint of the shown one in QStackedWidget.
110+
if (WalletView* view_about_to_hide = currentWalletView(); view_about_to_hide != nullptr) {
111+
QSizePolicy sp = view_about_to_hide->sizePolicy();
112+
sp.setHorizontalPolicy(QSizePolicy::Ignored);
113+
view_about_to_hide->setSizePolicy(sp);
114+
}
115+
109116
WalletView *walletView = mapWalletViews.value(wallet_model);
110-
walletStack->setCurrentWidget(walletView);
111117
assert(walletView);
118+
119+
// Set or restore the default QSizePolicy which could be set to QSizePolicy::Ignored previously.
120+
QSizePolicy sp = walletView->sizePolicy();
121+
sp.setHorizontalPolicy(QSizePolicy::Preferred);
122+
walletView->setSizePolicy(sp);
123+
walletView->updateGeometry();
124+
125+
walletStack->setCurrentWidget(walletView);
112126
walletView->updateEncryptionStatus();
113127
}
114128

0 commit comments

Comments
 (0)