I need to create an element like ComboBox which is combination of LineEdit and a Button.
QHBoxLayout *lineEditWithButtonForm = new QHBoxLayout( this );
lineEditWithButtonForm->setSpacing( 0 );
lineEditWithButtonForm->setContentsMargins( 0, 0, 0, 0 );
m_lineEdit = new LineEdit;
m_lineEdit->setFixedHeight( 25 );
m_lineEdit->setStyleSheet( "QLineEdit{ padding-left: 10px; padding-right: 10px; border-width: 1px; border-style: solid; border-color: rgb(204,204,204) white rgb(204,204,204) rgb(204,204,204); }");
lineEditWithButtonForm->addWidget( m_lineEdit );
m_button = new Button;
m_button->setFixedSize( QSize( 40, 25 ) );
m_button->setText("Button");
m_button->setCursor( QCursor( Qt::PointingHandCursor ) );
m_button->setFocusPolicy( Qt::ClickFocus );
m_button->setStyleSheet( "QAbstractButton{ border-width: 1px; border-style: solid; border-color: rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) white;}");
lineEditWithButtonForm->addWidget( m_button );
But the element I get looks like this. There is small distance between 2 base elements in the lower side, meanwhile there is no distance in the upper side. I tried to test it with Qt Designer and the result is the same. Do I have error with my setStyleSheet?
OK I have error with setStyleSheet. It should be:
m_lineEdit->setStyleSheet( "QLineEdit{ padding-left: 10px; padding-right: 10px; border-width: 1px 0px 1px 1px; border-style: solid; border-color: rgb(204,204,204); }");
m_button->setStyleSheet( "QAbstractButton{ border-width: 1px 1px 1px 0px; border-style: solid; border-color: rgb(204,204,204);}");