Results 1 to 5 of 5

Thread: Elide modes for QTreeView ,QStandardItemModel

  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Elide modes for QTreeView ,QStandardItemModel

    Hello Everyone,

    I've come across a challenge when Using model view Architecture (QTreeView ,QStandardItemModel)
    where in i need to set different Elide modes for different columns in a tree view
    for eg column 1 setTextElideMode(Qt::ElideRight);
    column 2 setTextElideMode(Qt::ElideLeft);
    column 3 setTextElideMode(Qt::ElideMiddle);

    Please respond! thanks in advance..

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Elide modes for QTreeView ,QStandardItemModel

    You can use different modes by using a custom delegate. Subclass QStyledItemDelegate or QItemDelegate and use different values for different columns of the model. QFontMetrics::elidedText() will help you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Elide modes for QTreeView ,QStandardItemModel

    will you please provide little finer information on implementation basis(development) i am new to GUI development.
    thanks in advance

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Elide modes for QTreeView ,QStandardItemModel

    Have a look at QStyledItemDelegate::paint() and QStyleOptionViewItem. All you need to do is to set the text elide mode of the option you are given based on the column of the index and call the base class implementation with the modified option.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Elide modes for QTreeView ,QStandardItemModel

    Its working Thank you very much

Similar Threads

  1. QTreeView with QStandardItemModel
    By aekilic in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2011, 09:11
  2. Replies: 3
    Last Post: 20th October 2010, 11:37
  3. Replies: 3
    Last Post: 19th February 2010, 20:31
  4. QTreeView with QStandardItemModel
    By steg90 in forum Newbie
    Replies: 3
    Last Post: 16th May 2007, 09:28
  5. can't do a QTreeView with a QStandardItemModel
    By Nuria in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2006, 00:41

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.