问题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