Results 1 to 6 of 6

Thread: How to constantly refresh time on a view

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to constantly refresh time on a view

    Hi ALL,
    I am developing an application in which i want the clock to show continous time as of my PC(machine) time,when i run the application it shows the time but the time issnt refreshing ,it isnt changing at all ,i have QTimer for that purpose but it doesnt seem to work !!..
    anyhelp would be apprecited..

    HEADER FILE
    Qt Code:
    1. QTime time;
    2. QTimer *update;
    3. QFont fontTime;
    4. QString timeString;
    5. ..
    6. public slots:
    7. void updateTime();
    To copy to clipboard, switch view to plain text mode 

    SOURCE FILE
    Qt Code:
    1. time = QTime::currentTime();
    2. update = new QTimer();
    3. connect(update,SIGNAL(timeout()),this,SLOT(updateTime()));
    4. update->start(1000);
    5. timeString = time.toString("hh:mm A");
    6. .. ..
    7. timeItem = scene->addText(timeString);
    8. timeItem->setFont(fontTime);
    9. timeItem->setTextWidth(100);
    10. timeItem->setPos(TIME_TEXT_X,TIME_TEXT_Y);
    11. .. ..
    12. void TrainingUI::updateTime()
    13. {
    14. time = QTime::currentTime();
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 23rd June 2008 at 12:41. Reason: Changed [qtclass] to [code]

Similar Threads

  1. Refresh the Mainwindow at run time
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 15th November 2007, 13:16
  2. Replies: 9
    Last Post: 7th November 2006, 15:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.