Results 1 to 3 of 3

Thread: QVariant question

  1. #1
    Join Date
    Dec 2008
    Location
    chinese
    Posts
    47
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default QVariant question

    question:

    QVariant test("10.23"); //define a QVariant object
    test.canConvert(QVariant:ateTime)==true ? //the convert is success why?

    why ? the test object can convert to datetime ? i do't understand
    hope somebody help me ,thank

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: QVariant question

    Why shouldnt it be success ??
    QVariant supports QDateTime,,, and also QDateTime can form a datetime from string (QDateTime::fromString) . So probably canConvert checks if it can form a valid QDateTime object from string, if valid, it returns success

  3. #3
    Join Date
    Dec 2008
    Location
    chinese
    Posts
    47
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: QVariant question

    code is :
    QString str="kkk";
    QDateTime qdt=QDateTime::fromQString(str);
    qdt.canConvert(QVariant:ateTime)==true ?//it's puzzle
    why?

Similar Threads

  1. Getting Microsoft Word Object to SaveAs
    By jvwebb in forum Newbie
    Replies: 3
    Last Post: 2nd September 2008, 19:27
  2. QVariant custom/user type comparison
    By gri in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 14:36
  3. QVariant to QAxObject*
    By QDrow in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2008, 09:35
  4. QAbstractItemModel question
    By awhite1159 in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2008, 09:11
  5. Crash caused by QVariant (mis)use
    By mclark in forum Newbie
    Replies: 2
    Last Post: 31st October 2006, 15:05

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.