Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem setting a stylesheet
Forum Updated to NodeBB v4.3 + New Features

problem setting a stylesheet

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 296 Views
  • 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.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by
    #1

    Hi All,

    I want to pass the following push-button style settings into the setStyleSheet, and to reuse a few times:

      background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,
                    stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74);
    

    But I can't store the above settings as QString . Can you suggest a workaround?

    jsulmJ 1 Reply Last reply
    0
    • V viniltc

      Hi All,

      I want to pass the following push-button style settings into the setStyleSheet, and to reuse a few times:

        background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,
                      stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74);
      

      But I can't store the above settings as QString . Can you suggest a workaround?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @viniltc said in problem setting a stylesheet:

      But I can't store the above settings as QString

      Why not?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      1
      • jsulmJ jsulm

        @viniltc said in problem setting a stylesheet:

        But I can't store the above settings as QString

        Why not?

        V Offline
        V Offline
        viniltc
        wrote on last edited by
        #3

        @jsulm Hi

        I tried this:

        QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,
                        stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74)");
        

        it gives me errors:

        programkey.cpp:489:22: error: expected expression
        programkey.cpp:490:24: error: use of undeclared identifier 'stop'
        
        jsulmJ V 2 Replies Last reply
        0
        • V viniltc

          @jsulm Hi

          I tried this:

          QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,
                          stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74)");
          

          it gives me errors:

          programkey.cpp:489:22: error: expected expression
          programkey.cpp:490:24: error: use of undeclared identifier 'stop'
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @viniltc You can't split a string across several lines like this in C++
          Corrected version:

          QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,"
                          "stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74)");
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • V viniltc

            @jsulm Hi

            I tried this:

            QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa,
                            stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74)");
            

            it gives me errors:

            programkey.cpp:489:22: error: expected expression
            programkey.cpp:490:24: error: use of undeclared identifier 'stop'
            
            V Offline
            V Offline
            viniltc
            wrote on last edited by
            #5

            @viniltc
            solved it!
            Sorry , my bad! that string should be in one line!.

             QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 :   1, stop :   0.0 #ffd9aa, stop :   0.5 #ffbb6e, stop :   0.55 #feae42, stop :   1.0 #fedb74)");
            
            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 Extensions
            • Unsolved