Results 1 to 2 of 2

Thread: Internalization characters in the QML model

  1. #1
    Join Date
    Aug 2011
    Posts
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Internalization characters in the QML model

    Hi

    my program keeps list of strings which contains also latin-1 characters like a and o with dots. Problems is when these strings are passed to QML model entity conversions is not handled correctly and on UI strange characters are show ... So how and where conversions should take in action ?

    conponent is Listview which model filled in the C++ side using contextproperty functionaliy

    m_rootContext->setContextProperty("mainCategoryModel", QVariant::fromValue(dataList));

    and

    QList<Object> datalist

    conversion to Latin1 or toAscii has no effect in the C++ side, as

    QString CategoryObject::name() const
    {
    return m_category.m_categoryName.toLatin1();
    }


    Actually everthing it's get wrong at start. ...

    I do have something like this :

    static char *foo[2][2] = { { "1", "2" },
    { "Åke", "Ängtröm"} };

    QString test (foo[1][1]);
    qDebug() << test;


    and

    qDebug() << test;

    got output somthing like this :

    Ängtröm

    This is more qt c++ problem ....
    Last edited by matsukan; 26th September 2012 at 13:25.

  2. #2
    Join Date
    Aug 2011
    Posts
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Internalization characters in the QML model

    Solved,

    Little google-fu and I've read carefully documentation helps solve me this problem:

    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    cat.m_categoryName = codec->toUnicode(foo[1][0]);

Similar Threads

  1. Replies: 9
    Last Post: 14th February 2013, 19:39
  2. Event handlers for QTableView model / selection model.
    By hickscorp in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2011, 17:57
  3. Using model indices in complex model item relationships
    By hackerNovitiate in forum Newbie
    Replies: 0
    Last Post: 29th June 2011, 14:30
  4. Replies: 1
    Last Post: 24th February 2011, 05:54
  5. Model/view, apply a filter on model
    By remy_david in forum Qt Programming
    Replies: 4
    Last Post: 4th February 2011, 17:13

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.