• <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://m.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
            posted on 2011-10-27 12:06 逛奔的蝸牛 閱讀(6304) 評論(0)  編輯 收藏 引用 所屬分類: Qt
            久久精品成人影院| 亚洲色婷婷综合久久| 久久婷婷人人澡人人| 国产成人久久精品一区二区三区| 久久亚洲AV成人无码电影| 亚洲伊人久久大香线蕉苏妲己| 久久久久国产成人精品亚洲午夜| 午夜精品久久久久久99热| 99久久婷婷国产一区二区| 久久久精品人妻一区二区三区蜜桃| 久久人人爽人人爽人人AV| 久久久久久国产a免费观看不卡| 一本色道久久88精品综合| 久久艹国产| 久久这里只有精品久久| 久久超乳爆乳中文字幕| 一本久久a久久精品综合香蕉| 国内精品久久久人妻中文字幕| 久久精品成人一区二区三区| 精品午夜久久福利大片| 久久久女人与动物群交毛片 | 国产精品久久久久a影院| 久久亚洲欧美日本精品| 久久夜色精品国产噜噜麻豆 | 大美女久久久久久j久久| 久久婷婷五月综合国产尤物app| 久久综合九色欧美综合狠狠 | 精品久久久久久国产免费了| 高清免费久久午夜精品| MM131亚洲国产美女久久| 久久婷婷色综合一区二区| 久久久久久久91精品免费观看| 精品久久久久久久久久久久久久久| 久久综合丁香激情久久| 国内精品久久久久影院日本| 久久国产乱子伦免费精品| 久久精品国产亚洲AV无码麻豆 | 怡红院日本一道日本久久| 久久婷婷五月综合国产尤物app| 一本一道久久综合狠狠老| 老男人久久青草av高清|