• <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
            高清免费久久午夜精品| 久久97久久97精品免视看秋霞| 思思久久精品在热线热| 中文精品久久久久人妻不卡| 久久91精品国产91久久户| 合区精品久久久中文字幕一区| 久久久久人妻精品一区| 久久黄视频| 国产精品久久毛片完整版| 最新久久免费视频| 婷婷综合久久中文字幕| 亚洲午夜久久久久久噜噜噜| 久久99国产精品成人欧美| 久久久久亚洲AV无码麻豆| 亚洲国产精品无码久久青草| 久久免费国产精品一区二区| 亚洲va中文字幕无码久久不卡| 久久综合久久性久99毛片| 久久久综合九色合综国产| 无码人妻久久一区二区三区免费丨 | 国产精品va久久久久久久| 午夜精品久久久久久毛片| 思思久久99热免费精品6| 91久久精品国产免费直播| 久久精品国产亚洲AV无码麻豆| 国内精品伊人久久久影院| 久久久精品日本一区二区三区| 久久国产精品国产自线拍免费| 色欲久久久天天天综合网精品 | 精品视频久久久久| 久久亚洲国产午夜精品理论片| 1000部精品久久久久久久久| 久久香综合精品久久伊人| 漂亮人妻被黑人久久精品| 久久婷婷五月综合97色| 久久精品国产亚洲AV香蕉| 国产精品99久久99久久久| 好属妞这里只有精品久久| 久久精品国产99国产精品澳门| 久久国产精品久久久| 国内精品久久久久久麻豆|