LineEdit style sheet



  • Hi,
    I have the following in my code:

        ui->LineEdit_Name->setStyleSheet("QLineEdit{ "
                                            "background-color:rgb(202, 255, 227);"
                                            "border: 2px solid gray;"
                                            "border-radius: 10px;"
                                            "padding: 0 8px;"
                                            "selection-background-color: darkgray;"
                                            "font-size: 16px;}"
                                            "QLineEdit:focus { "
                                            "background-color:rgb(192, 192, 255);}"
                                            );
    

    This works from code. But is it possible to define this in the Designer?
    When I choose change style sheet and add

    background-color:rgb(202, 255, 227); 
    border: 2px solid gray; 
    border-radius: 10px; 
    padding: 0 8px; 
    selection-background-color: darkgray; 
     font-size: 16px;
      focus {  
       background-color:rgb(192, 192, 255)}
    ``
    nothing happens though the window says it is a valid style sheet.
    Thank you for your help.


  • @gabor53
    try separating each line with \n .


  • Moderators

    @gabor53
    why don't you set the exact same stylesheet in the designer too?!



  • I tried but with "" it says the style is invalid.



  • QLineEdit{ background-color:rgb(202, 255, 227);
    border: 2px solid gray;
    border-radius: 10px;
    padding: 0 8px;
    selection-background-color: darkgray;
    font-size: 16px;}
    QLineEdit:focus { background-color:rgb(192, 192, 255);}

    Try to add this to your lineedit in the Designer.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.