Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Lost QTableWidget's ability to use StyleSheet

    General and Desktop
    2
    5
    103
    Loading More Posts
    • 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.
    • Driftwood
      Driftwood last edited by

      I have a QTableWidget (Qt Creator 4.14.2) that refuses to be styled. This is the code I'm using, code that worked like a charm last year when I was using Qt. But now, it's dead.

       ui->tableWidget_Customers->setStyleSheet("alternate-background-color: #d3eaea;");
       ui->tableWidget_Customers->horizontalHeader()->setStyleSheet
          ("QHeaderView::section { color: white; background-color:teal }"); 
       ui->tableWidget_Customers->verticalHeader()->setStyleSheet
          ("QHeaderView::section { color: white; background-color:teal }");
      

      I've noticed this about Qt: If it works today, just wait for tomorrow and it won't. They have a knack of "fixing" what isn't broken.

      Qt-6.3.1 | Qt Creator 8.0.0
      Win X Pro | Linux Mint 20.3

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Which version of Qt are you using exactly ?
        Can you provide a minimal compilable example that shows that behaviour ?

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

        Driftwood 1 Reply Last reply Reply Quote 0
        • Driftwood
          Driftwood @SGaist last edited by Driftwood

          @SGaist - This is what I have:

          {noformat}
          Qt 5.15.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160406 (Red Hat 5.3.1-6)) on "xcb" 
          OS: Linux Mint 20.2 [linux version 5.4.0-80-generic]
          
          Environment:
            QT_ACCESSIBILITY="1"
            QT_QPA_PLATFORMTHEME="qt5ct"
          
          Features: QT_NO_EXCEPTIONS
          
          Library info:
            PrefixPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt
            DocumentationPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/doc
            HeadersPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/include
            LibrariesPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/lib
            LibraryExecutablesPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/libexec
            BinariesPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/bin
            PluginsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/plugins
            ImportsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/imports
            Qml2ImportsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/qml
            ArchDataPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt
            DataPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt
            TranslationsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/translations
            ExamplesPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/examples
            TestsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt/tests
            SettingsPath: /home/fmc/Qt6/Tools/QtCreator/lib/Qt
          

          If needed, I'll create a minimal-usage scenario.

          Qt-6.3.1 | Qt Creator 8.0.0
          Win X Pro | Linux Mint 20.3

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Yes a minimal compilable example will be a good thing.

            Are you using your distribution provided Qt or one that you installed using the online installer ?

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

            Driftwood 1 Reply Last reply Reply Quote 0
            • Driftwood
              Driftwood @SGaist last edited by

              @SGaist - I got it from the Qt website. When I installed it, I watched it use my default Qt e-mail address and password before downloading myriad files.

              As for the minimal asking, I just determined this isn't a Qt issue. Let me explain.

              I don't use Qt's editor. I use CLion instead. When I run this in Qt (which I never do), the styling works fine. However, when I run it in CLion, the app takes on my system-wide theme. So I'm thinking this may be a CLion issue, since the styling works perfectly when I run the app out of Qt Creator. I hate days like this :D

              Qt-6.3.1 | Qt Creator 8.0.0
              Win X Pro | Linux Mint 20.3

              1 Reply Last reply Reply Quote 0
              • First post
                Last post