Skip to content

Commit

Permalink
qt: Stop the effect of hidden widgets on the size of QStackedWidget
Browse files Browse the repository at this point in the history
Layouts of the hidden widgets, those are children of QStackedWidget,
could prevent to adjust the size of the parent widget in the
WalletFrame widget.

Github-Pull: bitcoin-core/gui#176
Rebased-From: af58f5b
(cherry picked from commit bdc64c9)
  • Loading branch information
hebasto authored and apoelstra committed Sep 21, 2021
1 parent 4630083 commit 1f68875
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,24 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
{
if (mapWalletViews.count(wallet_model) == 0) return;

// Stop the effect of hidden widgets on the size hint of the shown one in QStackedWidget.
WalletView* view_about_to_hide = currentWalletView();
if (view_about_to_hide) {
QSizePolicy sp = view_about_to_hide->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Ignored);
view_about_to_hide->setSizePolicy(sp);
}

WalletView *walletView = mapWalletViews.value(wallet_model);
walletStack->setCurrentWidget(walletView);
assert(walletView);

// Set or restore the default QSizePolicy which could be set to QSizePolicy::Ignored previously.
QSizePolicy sp = walletView->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Preferred);
walletView->setSizePolicy(sp);
walletView->updateGeometry();

walletStack->setCurrentWidget(walletView);
walletView->updateEncryptionStatus();
}

Expand Down

0 comments on commit 1f68875

Please sign in to comment.