展開全部
m_btnSearch=newQPushButton(this);
QIconsearchIcon(":/CJWidgt/Resources/search.png");
m_btnSearch->setStyleSheet("border-style:solid");
m_btnSearch->setFlat(true);
m_btnSearch->setIcon(searchIcon);
m_btnSearch->setIconSize(QSize(24,24));
m_btnSearch->setCursor(Qt::PointingHandCursor);
m_btnSearch->setFixedSize(24,24);
m_btnSearch->setToolTip(QStringLiteral("查詢"));
//防止文本框輸入內(nèi)容位于按鈕之下
QMarginsmargins=ui.lineSearchContent->textMargins();
ui.lineSearchContent->setTextMargins(margins.left(),margins.top(),m_btnSearch->width(),margins.bottom());
QHBoxLayout*pSearchLayout=newQHBoxLayout();
pSearchLayout->addStretch();
pSearchLayout->addWidget(m_btnSearch);
pSearchLayout->setSpacing(0);
pSearchLayout->setContentsMargins(0,0,0,0);
ui.lineSearchContent
->setLayout(pSearchLayout);