• <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>

            逛奔的蝸牛

            我不聰明,但我會很努力

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

            效果圖如下:





            工程文件:/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);           // 設置按鈕的大小為圖片的大小

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

                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);


                // 設置輸入框中文件輸入區,不讓輸入的文字在被隱藏在按鈕下

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


                // 設置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 寫到代碼里, 實際工作中應該放到專用的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 逛奔的蝸牛 閱讀(6319) 評論(0)  編輯 收藏 引用 所屬分類: Qt
            99久久精品免费看国产一区二区三区| 精品无码久久久久久久动漫| 欧美午夜精品久久久久久浪潮| 国产—久久香蕉国产线看观看 | 四虎影视久久久免费| 中文字幕久久精品| 91精品久久久久久无码| 怡红院日本一道日本久久 | 国产欧美久久久精品| 久久艹国产| 久久se精品一区二区| 久久久久亚洲AV无码观看| 久久AⅤ人妻少妇嫩草影院| 人妻少妇久久中文字幕一区二区 | 精品国产一区二区三区久久久狼| 久久最新精品国产| segui久久国产精品| 国产精品99久久精品| 久久综合狠狠综合久久激情 | 国产ww久久久久久久久久| 亚洲国产精品无码久久久秋霞2| 久久久久免费精品国产| 久久久免费精品re6| 久久婷婷国产麻豆91天堂| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 综合网日日天干夜夜久久| 国产香蕉久久精品综合网| 亚洲精品无码久久久影院相关影片 | 精品久久久久久国产免费了| 国产国产成人精品久久| 热久久最新网站获取| 精品久久久噜噜噜久久久| 国产激情久久久久影院| 精品综合久久久久久97| 久久久久亚洲爆乳少妇无| 久久狠狠高潮亚洲精品| 久久国产AVJUST麻豆| 欧美精品一区二区精品久久| 久久精品国产亚洲av麻豆色欲| 久久久久99精品成人片| 日本免费一区二区久久人人澡 |