Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTableView stylesheet
Qt 6.12 LTS is out! See what's new in the release blog

QTableView stylesheet

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Giovanna
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you show your stylesheet ? And the way you use it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Giovanna
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It depends on the number of style sheet and their size but yes heaving customisation can trigger some slowdowns.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Giovanna
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I don't know, I don't have access to the code to check.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt
              • Unsolved