Results 1 to 6 of 6

Thread: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetItem.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI

    Yaa actually I had two strings eg. "String1" and "String2" I had inserted these strings in a QTreeWidget

    Qt Code:
    1. QTreeWidget *treeWidget = new QTreeWidget(this);
    2. QTreeWidgetItem *item1 = new QTreeeWidgetItem(treeWidget);
    3. item1->setText(0,"String1");
    4. tem1->setFont(0,font1);
    5. QTreeWidgetItem *item2 = new QTreeeWidgetItem(item1);
    6. item2->setText(0,"String2");
    7. tem1->setFont(0,font2);
    To copy to clipboard, switch view to plain text mode 

    The output is:

    String1
    String2

    String1 is the parent of String2 and treeWidget is parent of String1

    But I want both the strings should be of the same parent, but should be split and with the different fonts. That I had shown in the Attached file.
    Last edited by Lykurg; 23rd September 2010 at 13:56. Reason: missing [code] tags
    Always Believe in Urself
    Merry

  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: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI

    Please use the [code] tags next time. And in your code I can't see a custom delegate nor setItemWidget(). So if you don't try what I suggest you, I really can't help you. I won't provide a ready to use solution!

Similar Threads

  1. QTreeWidgetItem
    By bismitapadhy in forum Qt Programming
    Replies: 12
    Last Post: 7th January 2011, 10:48
  2. moving QTreeWidgetItem
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2009, 20:17
  3. QTreeWidgetItem ?
    By allensr in forum Qt Programming
    Replies: 5
    Last Post: 3rd January 2007, 17:51
  4. QTreeWidgetItem
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2006, 19:52
  5. QTreeWidgetItem
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2006, 15:07

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.