• <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 逛奔的蝸牛 閱讀(6302) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Qt
            国内精品久久久人妻中文字幕 | 久久久久无码专区亚洲av| 精品久久久久久无码国产| 久久91精品国产91久| 久久丫精品国产亚洲av不卡 | 亚洲а∨天堂久久精品| 久久精品国产99久久无毒不卡 | 久久久久久国产精品免费无码| 狠狠色伊人久久精品综合网 | 99久久婷婷免费国产综合精品| 99久久精品九九亚洲精品| 久久国语露脸国产精品电影| 91精品国产91久久久久久蜜臀| 亚洲国产精品无码成人片久久| 国内精品伊人久久久久网站| aaa级精品久久久国产片| 国产69精品久久久久APP下载| 国产精品久久精品| 无码人妻久久一区二区三区免费丨| 国产免费久久精品丫丫| 一本久久久久久久| 久久亚洲AV成人无码电影| 97香蕉久久夜色精品国产| 亚洲欧美国产精品专区久久| 国产成人久久久精品二区三区| 国产精品免费看久久久| 国产亚洲精久久久久久无码| 久久久久高潮综合影院| 东方aⅴ免费观看久久av| 久久久午夜精品福利内容| 日本精品久久久久久久久免费| 久久国产精品一区| 久久久久无码中| 亚洲国产成人久久一区WWW| 久久成人18免费网站| 久久青青草原精品国产软件| 久久综合久久性久99毛片| 日本亚洲色大成网站WWW久久| 久久无码国产| 色播久久人人爽人人爽人人片AV| 久久久SS麻豆欧美国产日韩|