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. PySide2 and string based style for quick testing...

PySide2 and string based style for quick testing...

Scheduled Pinned Locked Moved Solved General and Desktop
qstylesheetpyside2
6 Posts 4 Posters 578 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    How can I properly do this ? :

        style = """
        {
            background-color : rgba(64,64,64,255);
        };
        
        QLabel { 
            color: rgb(50, 50, 50); 
            font-size: 11px; 
            background-color: rgba(188, 188, 188, 50); 
            border: 1px solid rgba(188, 188, 188, 250); 
        } ;
        
        QSpinBox 
        { 
            color: rgb(50, 50, 50); 
            font-size: 11px; 
            background-color: rgba(255, 188, 20, 50); 
        };
        """
    
        model = QGraphicsScene()
    
        view = QGraphicsView()
        view.setStyleSheet(style)
    

    It seems to not work as is

    TIA

    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Not even when " is on same line/ no newline?

      s = """ this is a very
              long string if I had the
              energy to type more and more ..."""
      
      or
       s = ("this is a very"
            "long string too"
            "for sure ..."
           )
      
      
      1 Reply Last reply
      0
      • D Dariusz

        Hey

        How can I properly do this ? :

            style = """
            {
                background-color : rgba(64,64,64,255);
            };
            
            QLabel { 
                color: rgb(50, 50, 50); 
                font-size: 11px; 
                background-color: rgba(188, 188, 188, 50); 
                border: 1px solid rgba(188, 188, 188, 250); 
            } ;
            
            QSpinBox 
            { 
                color: rgb(50, 50, 50); 
                font-size: 11px; 
                background-color: rgba(255, 188, 20, 50); 
            };
            """
        
            model = QGraphicsScene()
        
            view = QGraphicsView()
            view.setStyleSheet(style)
        

        It seems to not work as is

        TIA

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Dariusz
        I cannot spot anything wrong in your multi-line string. However, what are the } ;s? I don't recall there being any semi-colons after the close curly braces, these are not programming statements. Are they interfering with the behaviour?

        D 1 Reply Last reply
        1
        • JonBJ JonB

          @Dariusz
          I cannot spot anything wrong in your multi-line string. However, what are the } ;s? I don't recall there being any semi-colons after the close curly braces, these are not programming statements. Are they interfering with the behaviour?

          D Offline
          D Offline
          Dariusz
          wrote on last edited by
          #4

          @JonB Old habbits of C++ coding I think.

          I removed them, tried different options. My style still don't change :- (

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

            Hi,

            What exactly doesn't work ?

            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
            1
            • D Offline
              D Offline
              Dariusz
              wrote on last edited by
              #6

              I had to replace this :

               style = """
                  {
                      background-color : rgba(64,64,64,255);
                  };
              

              With either:

               style = """
                  *{
                      background-color : rgba(64,64,64,255);
                  };
              

              Or

               style = """
                  QWidget {
                      background-color : rgba(64,64,64,255);
                  };
              

              And then it works :- )

              1 Reply Last reply
              1

              • Login

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