Results 1 to 6 of 6

Thread: QTableView + sorting + numbers & special characters

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Lithuania
    Posts
    10
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question QTableView + sorting + numbers & special characters

    Hi all,
    For the first - sorry for my english!!!...

    OS: WinXP
    QT: 4.5.1 (opensource)
    Compiler: MinGW

    Please help me with sorting numbers & special characters in QTableView.

    set data to QStandardItemModel
    Qt Code:
    1. itemModel = new QStandardItemModel;
    2. int row = 0;
    3. while (query->next())
    4. {
    5. item = new QStandardItem;
    6. itemModel->setItem(row, 0, item);
    7. itemModel->setData(itemModel->index(row,0), Qt::Unchecked, Qt::CheckStateRole);
    8. item = new QStandardItem(tr("%0").arg(query->record().value("ltr_cust_code").toString()));
    9. itemModel->setItem(row, 1, item);
    10. item = new QStandardItem(tr("%0").arg(query->record().value("kk").toString()));
    11. itemModel->setItem(row, 2, item);
    12. //etc........
    13. row++;
    14. }
    To copy to clipboard, switch view to plain text mode 

    set QStandardItemModel to QTableView
    Qt Code:
    1. ui->tlvXMLList2->setModel(xmlModel2);
    2. ui->tlvXMLList2->setSortingEnabled(true);
    3. ui->tlvXMLList2->sortByColumn(1, Qt::AscendingOrder);
    To copy to clipboard, switch view to plain text mode 

    First problem:
    The 2'nd column has data which is int type, and sorting is something like that [1,10,11,...,2,21,...] I need that numbers will be sorted [1,2,...,10,11,...,21,...]

    Second problem:
    In 3'rd column data is text type and has lithuanian characters (ĄČĘĖĮÅ ŲŪŽ) (if you don't see the characters set character encoding on your browser Baltic (Windows-1257)). When I'm sorting data using this column then data sorts something like that [A,B,C,D,E,F,G,...,ĄČĘĖĮ,...]. In lithuanian language sorting of text with lithuanian characters is [A,Ą,B,C,Č,D,E,Ę,Ė,F,G,...]
    How do everything what I need ???

    Thank's
    Last edited by foggy-mind; 2nd June 2009 at 12:47.

Similar Threads

  1. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  2. Special character's HTML entity to string
    By Hiba in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2009, 14:05
  3. Refresh QTableView after sorting
    By araglin in forum Newbie
    Replies: 4
    Last Post: 18th December 2008, 22:13
  4. special characters in xml
    By khcbabu in forum Qt Programming
    Replies: 3
    Last Post: 6th November 2008, 22:10
  5. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18

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.