Results 1 to 1 of 1

Thread: Trouble using QTimeEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Trouble using QTimeEdit

    I'm trying to use a QTimeEdit widget for UTC time. After creating the widget, I call QTimeEdit::setTimeSpec(Qt::UTC). When the widget is displayed, the time is locked at 08:00:00. I can't change the time (I'm in the US Pacific time zone). If I don't set the TimeSpec, the widget works, but offsets programmatically entered times by the local difference from GMT. Is there a bug in QTimeEdit or more likely, am I missing something in setting up the QEditTime widget?

    Code snippet creating widget:
    Qt Code:
    1. QLabel* pDateLabel = new QLabel("Collection Date:", pRightWidget);
    2. mpDate = new QDateEdit(pRightWidget);
    3. mpDate->setTimeSpec(Qt::UTC);
    4. mpDate->setCalendarPopup(true);
    5. QLabel* pTimeLabel = new QLabel("Collection Time (GMT):", pRightWidget);
    6. mpTime = new QTimeEdit(pRightWidget);
    7. mpTime->setTimeSpec(Qt::UTC);
    8. mpTime->setDisplayFormat("HH:mm:ss");
    To copy to clipboard, switch view to plain text mode 

    Method setting the time:
    Qt Code:
    1. void DataCollectionWidget::setCollectionTime(const time_t& time)
    2. {
    3. QDateTime dateTime;
    4. dateTime.setTimeSpec(Qt::UTC);
    5. dateTime.setTime_t(time);
    6. if (dateTime.isValid())
    7. {
    8. mpDate->setDate(dateTime.date());
    9. mpTime->setTime(dateTime.time());
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    The QDateEdit widget seems to work fine with the call to setTimeSpec(Qt::UTC), just the QTimeEdit widget is locked. QTimeEdit also locks up for Qt::OffsetFromUTC, but works fine (except I don't want the local time zone offset) for Qt::LocalTime.

    Dick
    Last edited by wysota; 17th October 2009 at 10:19. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 15th April 2009, 09:00
  2. Hourspinner in Qt3 QTimeEdit
    By user_mail07 in forum Qt Programming
    Replies: 0
    Last Post: 5th February 2009, 02:34
  3. [Qt] slot of QTimeEdit [problem resolved]
    By scorpiondezer in forum Qt Programming
    Replies: 8
    Last Post: 1st July 2008, 17:45
  4. QtimeEdit
    By mickey in forum Qt Programming
    Replies: 4
    Last Post: 11th July 2006, 18:04
  5. How to make QTimeEdit Box readable only
    By Krishnacins in forum Qt Programming
    Replies: 3
    Last Post: 6th March 2006, 08: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
  •  
Qt is a trademark of The Qt Company.