1.本文达到效果如下:
2.代码如下
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
resize(600, 400);
QComboBox* box = new QComboBox (this);
m_lineeidt = new QLineEdit (box);
m_lineeidt->setObjectName("lineedit");
m_lineeidt->setAutoFillBackground(true);
m_lineeidt->setStyleSheet("QLineEdit#lineedit,QLineEdit#lineedit:disabled{ border: none; font: 13px \"Microsoft YaHei\"; color: black; margin: 0px 20px 0px 1px;background: white;}");
connect(box, SIGNAL(currentIndexChanged(const QString&)), m_lineeidt, SLOT(setText(const QString&)));
QHBoxLayout* layoutBox = new QHBoxLayout; layoutBox->setSpacing(0);layoutBox->setMargin(0);
box->setLayout(layoutBox);
layoutBox-&