64,654
社区成员
发帖
与我相关
我的任务
分享
#ifndef RBG_LOG_TOOLS_H
#define RBG_LOG_TOOLS_H
#include <QtWidgets/QMainWindow>
#include "ui_rbg_log_tools.h"
#include <QPushButton>
#include <QMouseEvent>
#include <QLineEdit>
#include <QLabel>
class RBG_LOG_TOOLS : public QMainWindow
{
Q_OBJECT
public:
RBG_LOG_TOOLS(QWidget *parent = 0);
~RBG_LOG_TOOLS();
private:
Ui::RBG_LOG_TOOLSClass ui;
public:
QPushButton *pButtonStart;
QPushButton *pButtonStop;
QLabel *plabel;
public:
void mouseReleaseEvent(QMouseEvent *e);
void on_button_start( );
};
#endif // RBG_LOG_TOOLS_H
#include "rbg_log_tools.h"
#include <QTextCodec>
#include <QMessageBox>
RBG_LOG_TOOLS::RBG_LOG_TOOLS(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); // 改为GBK编码
QString strMessage = QString::fromLocal8Bit("RBG日志下载工具");
this->setWindowTitle(strMessage);
this->setMaximumSize(400, 300);
this->setMinimumSize(400, 300);
int iWindWidth = this->width( );
int iwindHeigh = this->height( );
int iButtonSatrtX;
int iButtonSatrtY;
int iButtonStopX;
int iButtonStopY;
pButtonStart = new QPushButton(QString::fromLocal8Bit("开始"), this);
pButtonStart->move( iWindWidth/4, (iwindHeigh*8)/10);
pButtonStart->show( );
pButtonStop = new QPushButton( QString::fromLocal8Bit("关闭"), this);
pButtonStop->move( iWindWidth/2, (iwindHeigh*8)/10);
plabel = new QLabel( QString::fromLocal8Bit("我是 QLabel"), this);
plabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
plabel->setAlignment(Qt::AlignBottom | Qt::AlignVCenter);
plabel->setGeometry(QRect(iWindWidth/6, iwindHeigh/10, (iWindWidth*4)/6, iWindWidth/10));
//两次的绑定都不生效
connect( plabel, SIGNAL(clicked()), this, SLOT(on_button_start()));
connect( pButtonStop, SIGNAL(clicked()), this, SLOT(quit()));
}
RBG_LOG_TOOLS::~RBG_LOG_TOOLS()
{
}
//这个槽函数无法触发
void RBG_LOG_TOOLS::on_button_start( )
{
QMessageBox::warning(this, QString("test"), QString("Hello"), QMessageBox::Yes, QMessageBox::Ignore );
}
void RBG_LOG_TOOLS::mouseReleaseEvent(QMouseEvent *e)
{
}