• <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 逛奔的蝸牛 閱讀(6319) 評論(0)  編輯 收藏 引用 所屬分類: Qt
            中文字幕亚洲综合久久2| 久久97久久97精品免视看秋霞 | 久久影视国产亚洲| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 91精品国产高清久久久久久io| 国产激情久久久久影院老熟女免费 | 久久久中文字幕| 亚洲国产成人精品久久久国产成人一区二区三区综 | 久久www免费人成看国产片| 精品久久久无码人妻中文字幕| 久久精品成人免费看| 伊人久久大香线蕉亚洲五月天| 91精品国产91久久久久久青草 | 久久久久一本毛久久久| 人妻精品久久久久中文字幕69 | 亚洲av伊人久久综合密臀性色 | 一本色道久久综合亚洲精品| 精品国产一区二区三区久久蜜臀| 中文字幕无码免费久久| 国产ww久久久久久久久久| 97久久久久人妻精品专区| 亚洲色大成网站www久久九| 久久国产午夜精品一区二区三区| 色偷偷偷久久伊人大杳蕉| 久久国产亚洲精品| 久久精品国产欧美日韩99热| 欧美日韩成人精品久久久免费看| 国产精品激情综合久久| 品成人欧美大片久久国产欧美...| 国产精品久久久久久久久免费| 久久天天躁狠狠躁夜夜网站| 香蕉久久av一区二区三区| 久久久久亚洲AV无码永不| 99久久无色码中文字幕人妻| 国产精品久久新婚兰兰| 欧美亚洲国产精品久久高清| 老男人久久青草av高清| 久久久亚洲AV波多野结衣| 思思久久99热只有频精品66| 亚洲熟妇无码另类久久久| 97久久超碰国产精品旧版|