{
Q_OBJECT
public:
public slots:
void upd();
private:
};
{
qw = qwi;
ql = qlb;
}
void test::upd()
{
connect(timer,SIGNAL(timeout()),this,SLOT(upd()));
timer->start(1000);
QString str
= "<font color='green'>";
str.append(time.toString("hh:mm:ss"));
str.append("</font>");
ql->setText(str);
qw->update();
}
int main (int argc, char *argv[])
{
window.resize(1024, 768);
timeLabel
->setFont
(QFont("Times",
20,
QFont::Bold));
timeLabel->setAlignment(Qt::AlignBottom | Qt::AlignRight);
QString str
= "<font color='green'>";
str.append(time.toString("hh:mm:ss"));
str.append("</font>");
timeLabel->setText(str);
window.setParent(0,Qt::FramelessWindowHint);
window.setPalette(palette);
quit.setPalette(palette);
quit.setGeometry(974, 0, 50, 20);
QObject::connect(&quit,
SIGNAL(clicked
()),
&app,
SLOT(quit
()));
window.show();
test *t = new test(&window,timeLabel);
t->upd();
return app.exec();
}
#include "main.moc"
class test : public QObject
{
Q_OBJECT
public:
test(QWidget *qwi,QLabel *qlb);
public slots:
void upd();
private:
QWidget *qw;
QLabel *ql;
};
test::test(QWidget *qwi, QLabel *qlb)
{
qw = qwi;
ql = qlb;
}
void test::upd()
{
QTimer *timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(upd()));
timer->start(1000);
QTime time = QTime::currentTime();
QString str = "<font color='green'>";
str.append(time.toString("hh:mm:ss"));
str.append("</font>");
ql->setText(str);
qw->update();
}
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(1024, 768);
QLabel *timeLabel = new QLabel(&window);
timeLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
timeLabel->setFont(QFont("Times", 20, QFont::Bold));
timeLabel->setAlignment(Qt::AlignBottom | Qt::AlignRight);
QString str = "<font color='green'>";
QTime time = QTime::currentTime();
str.append(time.toString("hh:mm:ss"));
str.append("</font>");
timeLabel->setText(str);
QPalette palette(QApplication::palette());
window.setParent(0,Qt::FramelessWindowHint);
palette.setColor(QPalette::Background, QColor("Black"));
QPushButton quit("Quit", &window);
quit.setFont(QFont("Times", 18, QFont::Bold));
palette.setColor(QPalette::Button, QColor("Blue"));
window.setPalette(palette);
quit.setPalette(palette);
quit.setGeometry(974, 0, 50, 20);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
window.show();
test *t = new test(&window,timeLabel);
t->upd();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks