Skip to content
Permalink
Browse files

Fix layout issues with color button editor widget

- widget was not left aligned
- widget would shrink to a small vertical height in crowded forms
  • Loading branch information
nyalldawson committed Apr 6, 2016
1 parent 4c704be commit 76282d5022db241535a220997859bf411c0aeb51
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/gui/editorwidgets/qgscolorwidgetwrapper.cpp
@@ -14,6 +14,7 @@
***************************************************************************/

#include "qgscolorwidgetwrapper.h"
#include <QLayout>

QgsColorWidgetWrapper::QgsColorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
@@ -42,14 +43,26 @@ void QgsColorWidgetWrapper::showIndeterminateState()

QWidget* QgsColorWidgetWrapper::createWidget( QWidget* parent )
{
QgsColorButtonV2* button = new QgsColorButtonV2( parent );
QWidget* container = new QWidget( parent );
QHBoxLayout* layout = new QHBoxLayout();
container->setLayout( layout );
layout->setMargin( 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
QgsColorButtonV2* button = new QgsColorButtonV2();
button->setContext( QString( "editor" ) );
return button;
layout->addWidget( button );
layout->addStretch();
container->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
return container;
}

void QgsColorWidgetWrapper::initWidget( QWidget* editor )
{
mColorButton = qobject_cast<QgsColorButtonV2*>( editor );
if ( !mColorButton )
{
mColorButton = editor->findChild<QgsColorButtonV2*>();
}

connect( mColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( valueChanged() ) );
}

0 comments on commit 76282d5

Please sign in to comment.
You can’t perform that action at this time.