• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會(huì)很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::

            效果圖如下:





            工程文件:/Files/biao/SearchButton.7z


            /**********************************************

             *                 SearchButton.h

             *********************************************/

            #ifndef SEARCHBUTTON_H

            #define SEARCHBUTTON_H


            #include <QPushButton>


            class QLineEdit;

            class QString;


            class SearchButton : public QPushButton {

                Q_OBJECT

            public:

                SearchButton(const QString &text, QLineEdit *edit);

            };


            #endif // SEARCHBUTTON_H



            /**********************************************

             *                  SearchButton.cpp

             *********************************************/

            #include "SearchButton.h"

            #include <QtGui/QLineEdit>

            #include <QtGui/QHBoxLayout>


            SearchButton::SearchButton(const QString &text, QLineEdit *edit)

                : QPushButton(text, edit) {

                QSize size = QSize(40, edit->sizeHint().height());

                setMinimumSize(size);

                setMaximumSize(size);           // 設(shè)置按鈕的大小為圖片的大小

                setFocusPolicy(Qt::NoFocus);    // 得到焦點(diǎn)時(shí),不顯示虛線框

                setFlat(true);

                setText(text);

                setCursor(QCursor(Qt::PointingHandCursor));


                QHBoxLayout *buttonLayout = new QHBoxLayout();

                buttonLayout->setContentsMargins(0, 0, 0, 0);

                buttonLayout->addStretch();

                buttonLayout->addWidget(this);

                edit->setLayout(buttonLayout);


                // 設(shè)置輸入框中文件輸入?yún)^(qū),不讓輸入的文字在被隱藏在按鈕下

                edit->setTextMargins(0, 1, size.width(), 1);


                // 設(shè)置style sheet

                /*.SearchButton {

                    background: gray; color: white; border: 1 solid gray;

                    min-width: 40px;

                }


                .SearchButton:hover {

                    background: black; color: white; border: 1 solid black;

                }


                .SearchButton:pressed {

                    background: white;

                    color: black;

                }*/


                // 為了方便起見, 幫把 style sheet 寫到代碼里, 實(shí)際工作中應(yīng)該放到專用的style sheet, 方便修改

                QString qss = QString(".SearchButton {background: gray; color: white; border: 1 solid gray;min-width: 40px;}")

                        + QString(".SearchButton:hover {background: black; color: white; border: 1 solid black;}")

                        + QString(".SearchButton:pressed {background: white;color: black;}");

                setStyleSheet(qss);

            }


            /**********************************************

             *                  Widget.cpp

             *********************************************/

            #include "Widget.h"

            #include "ui_Widget.h"

            #include "SearchButton.h"


            Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) {

                ui->setupUi(this);

                new SearchButton(tr("搜索"), ui->lineEdit_1); // 使用方法

                new SearchButton(tr("搜索"), ui->lineEdit_2);

            }


            Widget::~Widget() {

                delete ui;

            }


            @import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
            posted on 2011-10-27 12:06 逛奔的蝸牛 閱讀(6283) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Qt
            久久综合给合久久狠狠狠97色69| 看全色黄大色大片免费久久久| 久久人人爽人人爽人人片AV东京热 | 久久强奷乱码老熟女网站| 久久这里有精品视频| A级毛片无码久久精品免费| 精品国产乱码久久久久久郑州公司 | 国内精品久久久久久野外| 久久国产影院| 性做久久久久久久久老女人| 国产午夜久久影院| 亚洲国产精品成人久久蜜臀| 久久A级毛片免费观看| 久久久久亚洲AV成人网| 浪潮AV色综合久久天堂| 久久伊人中文无码| 波多野结衣中文字幕久久| 久久九九兔免费精品6| 久久www免费人成看国产片| 精品久久无码中文字幕| 久久婷婷五月综合成人D啪| 91久久香蕉国产熟女线看| 亚洲中文久久精品无码ww16 | 人妻无码久久精品| 国产ww久久久久久久久久| 久久超乳爆乳中文字幕| 久久天天婷婷五月俺也去| 亚洲性久久久影院| 国产国产成人久久精品| 国产精品久久久久…| 久久久久亚洲AV无码永不| 一本久久a久久精品亚洲| yy6080久久| 少妇人妻综合久久中文字幕| 武侠古典久久婷婷狼人伊人| 久久99精品国产99久久6| 国产成人精品久久亚洲高清不卡 | 国产精品美女久久久久| MM131亚洲国产美女久久| 狠狠狠色丁香婷婷综合久久五月 | 午夜肉伦伦影院久久精品免费看国产一区二区三区 |