Use QGridLayout in ExpandableRadioButton to align widget with label.

This commit is contained in:
Teo Mrnjavac 2015-11-06 17:17:53 +01:00
parent 40ee57bed1
commit 02c345e3be
2 changed files with 11 additions and 7 deletions

View File

@ -22,7 +22,7 @@
#include <utils/CalamaresUtilsGui.h> #include <utils/CalamaresUtilsGui.h>
#include <widgets/ClickableLabel.h> #include <widgets/ClickableLabel.h>
#include <QBoxLayout> #include <QGridLayout>
ExpandableRadioButton::ExpandableRadioButton( QWidget* parent ) ExpandableRadioButton::ExpandableRadioButton( QWidget* parent )
@ -32,10 +32,10 @@ ExpandableRadioButton::ExpandableRadioButton( QWidget* parent )
QBoxLayout* mainLayout = qobject_cast< QBoxLayout* >( layout() ); QBoxLayout* mainLayout = qobject_cast< QBoxLayout* >( layout() );
mainLayout->setDirection( QBoxLayout::TopToBottom ); mainLayout->setDirection( QBoxLayout::TopToBottom );
mainLayout->setContentsMargins( 0, 0, 0, 0 ); mainLayout->setContentsMargins( 0, 0, 0, 0 );
QBoxLayout* prettyRadioButtonLayout = new QHBoxLayout; m_gridLayout = new QGridLayout;
prettyRadioButtonLayout->addWidget( m_radio ); m_gridLayout->addWidget( m_radio, 0, 0 );
prettyRadioButtonLayout->addWidget( m_label ); m_gridLayout->addWidget( m_label, 0, 1 );
mainLayout->addLayout( prettyRadioButtonLayout ); mainLayout->addLayout( m_gridLayout );
} }
@ -51,13 +51,13 @@ ExpandableRadioButton::setExpandableWidget( QWidget* widget )
{ {
if ( m_expandableWidget ) if ( m_expandableWidget )
{ {
layout()->removeWidget( m_expandableWidget ); m_gridLayout->removeWidget( m_expandableWidget );
m_expandableWidget->deleteLater(); m_expandableWidget->deleteLater();
} }
m_expandableWidget = widget; m_expandableWidget = widget;
m_expandableWidget->setVisible( m_radio->isChecked() ); m_expandableWidget->setVisible( m_radio->isChecked() );
layout()->addWidget( m_expandableWidget ); m_gridLayout->addWidget( m_expandableWidget, 1, 1 );
updateGeometry(); updateGeometry();
connect( m_radio, &QRadioButton::toggled, connect( m_radio, &QRadioButton::toggled,

View File

@ -22,6 +22,8 @@
#include "PrettyRadioButton.h" #include "PrettyRadioButton.h"
class QGridLayout;
class ExpandableRadioButton : public PrettyRadioButton class ExpandableRadioButton : public PrettyRadioButton
{ {
Q_OBJECT Q_OBJECT
@ -37,6 +39,8 @@ public:
private: private:
QWidget* m_expandableWidget; QWidget* m_expandableWidget;
bool m_expanded; bool m_expanded;
QGridLayout* m_gridLayout;
}; };
#endif // EXPANDABLERADIOBUTTON_H #endif // EXPANDABLERADIOBUTTON_H