Results 1 to 3 of 3

Thread: QTreeWidget setCurrentItem difference height with the same setStyleSheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QTreeWidget setCurrentItem difference height with the same setStyleSheet

    case 0:
    if i do not use any setCurrentItem function in the QTreeWidget,all the item are normal

    Qt Code:
    1. QApplication a(argc, argv);
    2.  
    3. QString str1;
    4. str1.append("uistyle.css");
    5. QFile file(str1);
    6.  
    7. if(file.open(QFile::ReadOnly))
    8. {
    9. QString styleSheet = QObject::tr(file.readAll());
    10. a.setStyleSheet(styleSheet);
    11. file.close();
    12. }
    13.  
    14. MainWindow w;
    15. w.show();
    16. return a.exec();
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ui->setupUi(this);
    2. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
    3. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
    4. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
    To copy to clipboard, switch view to plain text mode 

    case 1:

    in the main function i have used the setStyleSheet and use it before the mainwindow's construct function

    if i use
    Qt Code:
    1. ui->setupUi(this);
    2. ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
    3. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
    4. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
    To copy to clipboard, switch view to plain text mode 
    the first and the last item height are UNNormal but the second and the third is NORMAL
    all the sub items are normal

    case 2:

    in the main function i have used the setStyleSheet and use it before the mainwindow's construct function

    Qt Code:
    1. ui->setupUi(this);
    2. ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
    3. ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
    4. //ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
    To copy to clipboard, switch view to plain text mode 
    the first the second and the last item height are UNNormal but the third is NORMAL
    all the sub items are normal

    case 3
    i change the order of mainwindow's construct function and the setStyleSheet func

    Qt Code:
    1. QApplication a(argc, argv);
    2.  
    3. MainWindow w; //to here
    4.  
    5. QString str1;
    6. str1.append("uistyle.css");
    7. QFile file(str1);
    8.  
    9. if(file.open(QFile::ReadOnly))
    10. {
    11. QString styleSheet = QObject::tr(file.readAll());
    12. a.setStyleSheet(styleSheet);
    13. file.close();
    14. }
    15.  
    16. //MainWindow w; //old position
    17. w.show();
    18. return a.exec();
    To copy to clipboard, switch view to plain text mode 
    all the item are normal

    why? the attachment is follow
    Attached Files Attached Files
    Last edited by trytoremeber963; 11th January 2011 at 02:02.

Similar Threads

  1. QToolButton & setStyleSheet
    By kavinsiva in forum Newbie
    Replies: 1
    Last Post: 3rd June 2010, 14:52
  2. Replies: 1
    Last Post: 21st November 2008, 16:06
  3. Problem to setstylesheet
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2008, 06:57
  4. using setStyleSheet
    By Weilor in forum Qt Programming
    Replies: 11
    Last Post: 18th January 2008, 13:41
  5. Replies: 2
    Last Post: 6th April 2006, 08:21

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.