huihuiwith 2014-12-25 01:35
浏览 2735

Qt中的星期英文显示,和timerId()的返回值

问题1:下面的是槽函数的定义,我想让 星期四 显示成英文应该怎么写,我Ubuntu是中文的
void MainWindow::timeUpdate()
{
QDateTime timeOfSystem = QDateTime::currentDateTime();
QString str = timeOfSystem.toString("yyyy-MM-dd hh:mm:ss dddd");
label->setText(str);
}

输出为:2014-12-25 09:30:33 星期四

我现在想把 星期四 显示成英文

问题2:下面程序不知是否有问题,总之重载的这个timerEvent()没有起作用
/////////下面是mainwindow.h//////////
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include
#include

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void timerEvent(QTimerEvent *);

private:
Ui::MainWindow *ui;
QLabel *label_2;
};
#endif // MAINWINDOW_H

////////////////下面是mainwindow.cpp///////////////
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include
#include

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

label_2 = new QLabel(this);
label_2->setText(tr("None"));
label_2->adjustSize();

startTimer(1000);   
startTimer(5000);   
startTimer(10000);  

}

MainWindow::~MainWindow()
{
delete ui;
delete label_2;
}

void MainWindow::timerEvent(QTimerEvent *t)
{
switch (t->timerId()) {
case 1 :
ui->label_1->setText(tr("产生一个随机数: %1").arg(qrand()%10));
break;
case 2 :
label_2->setText(tr("程序将会在5s后关闭. "));
break;
case 3 :
qApp->quit();
break;
default:
break;
}
}

我用cout << t->timerId(),这个值让我很不解:33554433

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建