• <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://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 逛奔的蝸牛 閱讀(6282) 評論(0)  編輯 收藏 引用 所屬分類: Qt
            伊人久久大香线蕉成人| 久久精品无码一区二区日韩AV| 久久天天躁狠狠躁夜夜2020一| 一本大道久久东京热无码AV| 久久久久99精品成人片直播| 久久精品一区二区三区中文字幕 | 国产精品久久久久久影院| 久久国产视屏| 久久夜色精品国产噜噜噜亚洲AV | 久久精品国产99国产精品| 久久综合给合久久国产免费| 久久久久久久亚洲精品| 91精品国产91久久久久福利| 久久亚洲精品国产亚洲老地址| a级成人毛片久久| 国产A三级久久精品| 天天影视色香欲综合久久| 久久久中文字幕| 久久久久99精品成人片试看| 午夜视频久久久久一区| 成人久久综合网| 99久久99这里只有免费费精品| 久久伊人中文无码| 久久国产免费直播| 91久久成人免费| 国产精品内射久久久久欢欢| 精品久久一区二区| 九九99精品久久久久久| 国产精品一区二区久久不卡| 久久久久亚洲AV无码专区体验| 久久久久亚洲AV无码观看| 久久久久亚洲av综合波多野结衣| 一级做a爰片久久毛片毛片| 亚洲国产精品一区二区三区久久 | 久久AⅤ人妻少妇嫩草影院| 一本色道久久88加勒比—综合| 精品国产91久久久久久久| 久久精品国产亚洲一区二区| 久久婷婷久久一区二区三区| 久久国产精品一区| 久久久久人妻一区二区三区|