Results 1 to 4 of 4

Thread: Time is not getting displayed using tostring function!

  1. #1
    Join Date
    Jan 2013
    Posts
    22
    Thanked 3 Times in 2 Posts
    Qt products
    Qt/Embedded

    Default Time is not getting displayed using tostring function!

    Hi,
    I am getting result of below code blank.
    is the format for time correct?
    what could be the problem?
    #include <QtGui>
    #include <QDateTime>
    #include <QTime>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QPushButton *button3 = new QPushButton;
    QString StartT;
    StartT = "24-1-2013 23:51:52:345";
    QDateTime StDt = QDateTime::fromString(StartT, "d-M-yyyy h:m:s:z");
    QTime T1;
    T1=StDt.time();

    QString T2s = T1.toString("h:m:s:z");
    button3->show();
    button3->setText(T2s);

    return a.exec();
    }

    Thanks,
    Sanujas

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Time is not getting displayed using tostring function!

    Please clean up your example to isolate the problem.

  3. #3
    Join Date
    Jan 2013
    Posts
    22
    Thanked 3 Times in 2 Posts
    Qt products
    Qt/Embedded

    Default Re: Time is not getting displayed using tostring function!

    can you pls explain me what exactly to clean up in the above code?

    Thanks,
    Sanujas

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Time is not getting displayed using tostring function!

    Why do you have push buttons in the code. They have nothing to do with the text e.g. And if you check single steps, you would where your code goes wrong. I can't guess, because on my machine it works as expected. (And there are [code] tags)

Similar Threads

  1. Custom type registration on QVariant & toString()
    By zickedi in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2012, 00:34
  2. Replies: 2
    Last Post: 6th December 2010, 21:36
  3. Replies: 10
    Last Post: 4th June 2010, 09:43
  4. QHostAddress::toString
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 22nd November 2008, 16:53
  5. Replies: 4
    Last Post: 20th December 2007, 11:51

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.