Results 1 to 2 of 2

Thread: Multiple Font in One Column of QTreeWidgetItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Multiple Font in One Column of QTreeWidgetItem

    Hi

    I am using Qt on MacOS. My software requirement is that We are displaying text in two line, First line will be in Bold Font and in second line, we are using small font,

    small sample code for this:

    QString strPath = QString(pEntry->cFilePath,pEntry->nPathLen/2);
    QString tmpFileName = "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:'Lucida Grande'; font-size:11pt; font-weight:200; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; \">";
    tmpFileName = tmpFileName + strFileName + "</span></p>\n";
    tmpFileName +="<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\">" + strPath + "</p>\n";

    QTreeWidgetItem *pItem = new QTreeWidgetItem;
    QLabel *pLabel = new QLabel;
    pLabel->setAutoFillBackground(true);
    pLabel->setText(tmpFileName);

    treeWidget->setItemWidget(pItem,0,pLabel);


    This sample code is correctly show the text in QTreeWidgetItem in two line using HTML tag and QLabel. But After adding few hundred QTreeWidgetItem in QTreeWidget, it started disappear the first column text, when I am moving the vertical scrollbar, But when resize the column 1, using draging column, it immedietly update and view the text in QTreeWidget.

    I searched this problem in google, i found one problem here link...
    http://www.qtcentre.org/archive/index.php/t-589.html

    it solution is the use QItemdelegate and customize setModelData,
    But program is developed is that fashion that, in this stage we can't use QItemDelegate to change whole program.

    I need some help to fix this bug without using QItemDelegate.

    I also see the following link:
    http://qt-project.org/doc/qt-4.8/qtr...#setItemWidget

    But no luck.

    Kindly tell me the solution for this as we are stuck at this point.


    Note: I have attached the screenshot regarding this Bug. Some Item of QTreeWidgetItem display and some Item of QTreeWidgetItem don't display,

    Kindly reply for the solution..
    Attached Images Attached Images

Similar Threads

  1. Replies: 11
    Last Post: 3rd March 2012, 22:21
  2. Replies: 7
    Last Post: 19th October 2010, 08:32
  3. Replies: 5
    Last Post: 23rd September 2010, 13:58
  4. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 08:02
  5. Replies: 2
    Last Post: 2nd December 2008, 05:37

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.