|
14 | 14 | ***************************************************************************/
|
15 | 15 |
|
16 | 16 | #include "qgscolorwidgetwrapper.h"
|
| 17 | +#include <QLayout> |
17 | 18 |
|
18 | 19 | QgsColorWidgetWrapper::QgsColorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
|
19 | 20 | : QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
|
@@ -42,14 +43,26 @@ void QgsColorWidgetWrapper::showIndeterminateState()
|
42 | 43 |
|
43 | 44 | QWidget* QgsColorWidgetWrapper::createWidget( QWidget* parent )
|
44 | 45 | {
|
45 |
| - QgsColorButtonV2* button = new QgsColorButtonV2( parent ); |
| 46 | + QWidget* container = new QWidget( parent ); |
| 47 | + QHBoxLayout* layout = new QHBoxLayout(); |
| 48 | + container->setLayout( layout ); |
| 49 | + layout->setMargin( 0 ); |
| 50 | + layout->setContentsMargins( 0, 0, 0, 0 ); |
| 51 | + QgsColorButtonV2* button = new QgsColorButtonV2(); |
46 | 52 | button->setContext( QString( "editor" ) );
|
47 |
| - return button; |
| 53 | + layout->addWidget( button ); |
| 54 | + layout->addStretch(); |
| 55 | + container->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); |
| 56 | + return container; |
48 | 57 | }
|
49 | 58 |
|
50 | 59 | void QgsColorWidgetWrapper::initWidget( QWidget* editor )
|
51 | 60 | {
|
52 | 61 | mColorButton = qobject_cast<QgsColorButtonV2*>( editor );
|
| 62 | + if ( !mColorButton ) |
| 63 | + { |
| 64 | + mColorButton = editor->findChild<QgsColorButtonV2*>(); |
| 65 | + } |
53 | 66 |
|
54 | 67 | connect( mColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( valueChanged() ) );
|
55 | 68 | }
|
|
0 commit comments