Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PySide2 and string based style for quick testing...



  • 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


  • Lifetime Qt Champion

    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 ..."
         )
    
    


  • @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?



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

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


  • Lifetime Qt Champion

    Hi,

    What exactly doesn't work ?



  • 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 :- )


Log in to reply