Unsolved QTableView stylesheet
-
Hi all,
I have a problem with the stylesheet I'd like to use for a tableview containing three columns and several rows. If a call the setStyleSheet function inside the panel constructor containing the tableview it doesn't work and the tableview is not populated even if i call the setModel function. (i have to set the style of indicator if it is checked or unchecked using images). If I call the setStyleSheet function when I open the panel containing the tableview, it works but it
causes a slowing down of the application.
Can you help me?
Thank you -
Hi and welcome to devnet,
Can you show your stylesheet ? And the way you use it ?
-
Hi,
I explain better the problem. I have a tableview in a qwidget containing one column with strings and two column with checkboxes. I'd like to change the style of checkbox. So, i tried to set the stylesheet calling the function setStyleSheet in the widget constructor:tableViewStyle.append("QTableView::indicator{background-color: transparent;}"); tableViewStyle.append("QTableView::indicator:unchecked{background-color: transparent;}"); tableViewStyle.append("QTableView::indicator:checked{image:url(:/new/MainWinImages/Images/V.PNG);}"); tableViewStyle.append("QTableView::indicator{width:40px;height:40px;}"); tableViewStyle.append("QTableView::indicator{margin-left:20%; margin-right:50%;}"); tableViewStyle.append("QTableView{background-color: rgb(149, 199, 236);}"); tableViewStyle.append("QTableView::indicator{width:40px;height:40px;}"); tableViewStyle.append("QTableView::indicator{margin-left:20%; margin-right:50%;}"); tableViewStyle.append("QTableView{background-color: rgb(149, 199, 236);}"); m_ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); m_ui->tableView->setStyleSheet(tableViewStyle);
I call the function setModel in the constructor too passing a reimplemented model. I notice that when I open the panel containing the tableview the function data of the model that populate the tableview is not called and the stylesheet has no effect. Instead, if I set the stylesheet when I open the panel and not in the constructor, everything work fine but I notice the application slows down., maybe because the stylesheet is heavy.
-
It depends on the number of style sheet and their size but yes heaving customisation can trigger some slowdowns.
-
For the reason i Tried to call the function to set the stylesheet at the beginning, when the application is loading. Why the list is not populated if i set the stylesheet in the constructor?
-
I don't know, I don't have access to the code to check.