Qt类

类QPushButton的头文件为#include <qpushbutton.h>

/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QPUSHBUTTON_H
#define QPUSHBUTTON_H

#include <QtGui/qabstractbutton.h>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Gui)

class QPushButtonPrivate;
class QMenu;
class QStyleOptionButton;

class Q_GUI_EXPORT QPushButton : public QAbstractButton
{
    Q_OBJECT

    Q_PROPERTY(bool autoDefault READ autoDefault WRITE setAutoDefault)
    Q_PROPERTY(bool default READ isDefault WRITE setDefault)
    Q_PROPERTY(bool flat READ isFlat WRITE setFlat)

public:
    explicit QPushButton(QWidget *parent=0);
    explicit QPushButton(const QString &text, QWidget *parent=0);
    QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0);
    ~QPushButton();

    QSize sizeHint() const;
    QSize minimumSizeHint() const;

    bool autoDefault() const;
    void setAutoDefault(bool);
    bool isDefault() const;
    void setDefault(bool);

#ifndef QT_NO_MENU
    void setMenu(QMenu* menu);
    QMenu* menu() const;
#endif

    void setFlat(bool);
    bool isFlat() const;

public Q_SLOTS:
#ifndef QT_NO_MENU
    void showMenu();
#endif

protected:
    bool event(QEvent *e);
#ifdef Q_WS_MAC
    bool hitButton(const QPoint &pos) const;
#endif // Q_WS_MAC
    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *);
    void focusInEvent(QFocusEvent *);
    void focusOutEvent(QFocusEvent *);
    void initStyleOption(QStyleOptionButton *option) const;
    QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0);

public:
#ifdef QT3_SUPPORT
    QT3_SUPPORT_CONSTRUCTOR QPushButton(QWidget *parent, const char* name);
    QT3_SUPPORT_CONSTRUCTOR QPushButton(const QString &text, QWidget *parent, const char* name);
    QT3_SUPPORT_CONSTRUCTOR QPushButton(const QIcon& icon, const QString &text, QWidget *parent, const char* name);
    inline QT3_SUPPORT void openPopup()  { showMenu(); }
    inline QT3_SUPPORT bool isMenuButton() const { return menu() !=  0; }
    inline QT3_SUPPORT void setPopup(QMenu* popup) {setMenu(popup); }
    inline QT3_SUPPORT QMenu* popup() const { return menu(); }
#endif

private:
    Q_DISABLE_COPY(QPushButton)
    Q_DECLARE_PRIVATE(QPushButton)
#ifndef QT_NO_MENU
    Q_PRIVATE_SLOT(d_func(), void _q_popupPressed())
#endif
};

QT_END_NAMESPACE

QT_END_HEADER

#endif // QPUSHBUTTON_H
时间: 2024-08-10 21:19:35

Qt类的相关文章

Qt 类外调用一个 private slots 函数

MainWindow中 private slots 函数 void print_on_log(QString strtemp);输出一个字符串到编辑窗口中 class MainWindow:publicQMainWindow {Q_OBJECTpublic:explicitMainWindow(QWidget*parent=0);~MainWindow();privateslots:voidprint_on_log(QStringstrtemp); 定义一个新类Test_one在此类中调用上面的

Qt国际化(Q_DECLARE_TR_FUNCTIONS() 宏给非Qt类添加翻译支持,以前没见过QTextEncoder和QTextDecoder和QLibraryInfo::location()和QEvent::LanguageChange)

Internationalization with Qt 应用程序的国际化就是使得程序能在国际间可用而不仅仅是在本国可用的过程. Relevant Qt Classes andAPIs 以下的类支持Qt的国际化. QTextCodec QTextDecoder QTextEncoder QTranslator QLocale Languages and WritingSystems 有时,国际化是比较简单的,例如,把美国的应用程序让澳大利亚或英国的用户可访问,只需要简单的改变拼写.但是,把美国的

可重入与线程安全(大多数Qt类是可重入,非线程安全的)

可重入与线程安全 在Qt文档中,术语“可重入”与“线程安全”被用来说明一个函数如何用于多线程程序.假如一个类的任何函数在此类的多个不同的实例上,可以被多个线程同时调用,那么这个类被称为是“可重入”的.假如不同的线程作用在同一个实例上仍可以正常工作,那么称之为“线程安全”的. 大多数c++类天生就是可重入的,因为它们典型地仅仅引用成员数据.任何线程可以在类的一个实例上调用这样的成员函数,只要没有别的线程在同一个实例上调用这个成员函数.举例来讲,下面的Counter 类是可重入的: class Co

Qt类中使用定时器

QT定时器只能使用在进程或线程中. QT类中如果需要定时器,可以把定时工作安排在一个线程中执行. class aaa : public QThread { Q_OBJECT ... protected: //重写run函数 void run(); public slots: void timerOut(); private: QTimer *timer; } aaa::aaa(QThread *parent):QThread(parent) { timer = new QTimer(0); co

Win32下 Qt与Lua交互使用(二):在Lua脚本中使用Qt类

话接上篇.成功配置好Qt+Lua+toLua后,我们可以实现在Lua脚本中使用各个Qt的类.直接看代码吧. #include "include/lua.hpp" #include <QWidget> #include <QApplication> #include <QFile> #include <QDebug> static int tolua_new_QWidget(lua_State* pState) { QWidget* wid

Win32下 Qt与Lua交互使用(四):在Lua脚本中自由执行Qt类中的函数

话接上篇.通过前几篇博客,我们实现在Lua脚本中执行Qt类中函数的方法,以及在Lua脚本中连接Qt对象的信号与槽. 但是,我们也能发现,如果希望在Lua脚本中执行Qt类的函数,就必须绑定一个真正实现功能的函数.如QWidget::show(),需要写一个在栈中取出widget指针,widget调用show()函数的方式.如果希望在Lua中调用大量函数,就需要编写大量的C++实现函数.有没有什么省时省力的好方法呢? 上一篇中我们实现了在Lua脚本中连接信号与槽.我们只是传过去了两个QObject的

Qt类继承图

对于学习Qt的,有一个Qt所有类的继承图表,是很有需要的.以下提供了Qt5.1的所有类的继承关系图.看的时候,可以放大和缩小.如需文档下载,可以加入最后的QQ学习群. Qt类继承图

QT5.4关联VS2010,配置VAssistX关联Qt类

1.参考网站:http://www.kavenblog.com/?p=272 2.下载插件:http://www.qt.io/zh-hans/download-open-source/#section-7 3.安装插件: 4.查看与配置 打开VS2010: QT5菜单项: 选择Qt Options 5.创建测试项目: OK,Test项目创建完成,具体如下: 我们编译一下项目: 1>—— 已启动生成: 项目: Test, 配置: Debug Win32 —— 1>生成启动时间为 2015/3/1

Qt类声明中Q_OBJECT的作用与报错解决

2017-06-22 周四 大雨 北京 院里 新建作图类,继承自QCUstomPlot类 因为需要同时作8张图,都要单坐标缩放的功能,因此想干脆新建一个类,继承自QCUstomPlot,把需要的功能都加上.类名取为QCUstomPlotPlus,最终成功版类代码如下: //声明.explicit是为了禁止隐式转换. class QCustomPlotPlus : public QCustomPlot { Q_OBJECT //重要! public: explicit QCustomPlotPlu