1 Attachment(s)
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
Code:
str1.append("uistyle.css");
if(file.
open(QFile::ReadOnly)) {
a.setStyleSheet(styleSheet);
file.close();
}
MainWindow w;
w.show();
return a.exec();
Code:
ui->setupUi(this);
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
case 1:
in the main function i have used the setStyleSheet and use it before the mainwindow's construct function
if i use
Code:
ui->setupUi(this);
ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
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
Code:
ui->setupUi(this);
ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(0));
ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(1));
//ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(2));
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
Code:
MainWindow w; //to here
str1.append("uistyle.css");
if(file.
open(QFile::ReadOnly)) {
a.setStyleSheet(styleSheet);
file.close();
}
//MainWindow w; //old position
w.show();
return a.exec();
all the item are normal
why? the attachment is follow
Re: QTreeWidget setCurrentItem difference height with the same setStyleSheet
what about my question? Is there any body download the attached files and test ?
Re: QTreeWidget setCurrentItem difference height with the same setStyleSheet
That's pretty strange. I tried setting the style sheet in the MainWindow ctor and it seems to work:
Code:
ui->treeWidget->setStyleSheet("::item { margin-top:2; margin-bottom:2; min-height:20;} "
"::item:selected:!active { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, "
"stop: 0 rgb(255,211,159), stop: 0.4 rgb(254,180,72), stop: 1 rgb(254,222,119));}"
"::item:selected:active { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, "
"stop: 0 rgb(66,180,255), stop: 1 rgb(0,152,255)); }"
"::item:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, "
"stop: 0 rgb(247,235,224), stop: 1 rgb(255,211,159));}");
Didn't get any warnings but maybe there is a problem parsing your css file.
Edit: I quit reading and tried your code before getting to case 3.