• <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://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 逛奔的蝸牛 閱讀(6309) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Qt
            国产精品伦理久久久久久| 国产亚洲精久久久久久无码AV| 午夜精品久久久内射近拍高清| 无码国内精品久久综合88 | 青青青国产精品国产精品久久久久| av无码久久久久不卡免费网站| 久久91这里精品国产2020| 亚洲国产精品无码久久久久久曰| 亚洲AV无码一区东京热久久| 久久免费美女视频| 久久人妻少妇嫩草AV无码专区 | 国产精品成人99久久久久 | 久久久国产精品亚洲一区| 91精品无码久久久久久五月天| 伊人久久大香线蕉综合网站| 久久精品国产一区二区三区日韩| 久久强奷乱码老熟女| 国产亚洲美女精品久久久久狼| 性做久久久久久久久浪潮| 久久99国内精品自在现线| 伊人久久精品影院| 久久久久久久综合综合狠狠| 色综合久久天天综合| 精品人妻久久久久久888| 伊人久久大香线焦AV综合影院| 久久久久国产一区二区三区| 国产精品成人久久久久久久| 久久96国产精品久久久| 久久久久亚洲av无码专区喷水| 伊人伊成久久人综合网777| 久久综合一区二区无码| 久久久久久国产精品无码下载| 久久精品国产99久久香蕉| 久久艹国产| 欧美亚洲另类久久综合婷婷| 伊人久久综在合线亚洲2019| 国产一区二区三区久久| 久久夜色精品国产欧美乱| 少妇人妻88久久中文字幕| 久久久久人妻一区精品性色av| 久久99精品久久只有精品|