• <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 逛奔的蝸牛 閱讀(6302) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Qt
            国内精品久久久久伊人av| 久久婷婷五月综合成人D啪| 97久久国产综合精品女不卡 | 品成人欧美大片久久国产欧美...| 亚洲中文久久精品无码| 久久99精品国产99久久| 国产午夜福利精品久久| 午夜视频久久久久一区| 亚洲国产精品无码成人片久久| 久久精品一区二区三区不卡| 久久播电影网| 无码精品久久久天天影视| 国产精品免费久久| 亚洲乱码精品久久久久..| 久久精品国产亚洲一区二区三区| 久久笫一福利免费导航| 伊人色综合久久| 久久久久久久精品成人热色戒| 97超级碰碰碰碰久久久久| 亚洲精品无码久久久久去q| 精品久久久久久国产牛牛app | 久久99精品久久久久久不卡| 亚洲AV日韩AV天堂久久| 久久精品一区二区三区中文字幕| 久久久久人妻精品一区二区三区| 久久久中文字幕日本| 精品一区二区久久| 亚洲欧美日韩中文久久| 99久久国产精品免费一区二区| 热RE99久久精品国产66热| 久久久精品一区二区三区| 久久狠狠高潮亚洲精品| 久久综合九色综合网站| 久久精品国产亚洲AV蜜臀色欲 | 日韩人妻无码一区二区三区久久 | 久久久久久伊人高潮影院| 亚洲成av人片不卡无码久久| 韩国三级中文字幕hd久久精品| 93精91精品国产综合久久香蕉| 欧美精品一本久久男人的天堂| 99久久久精品免费观看国产 |