Qt Set Background Color of QLineEdit

前端 未结 4 1176

I\'m trying to change the background color of the QLineEdit and I can\'t figure it out at all.

I tried using stylesheets originally like th

4条回答
  •  执笔经年
    2020-12-18 21:22

    You can set the background and text colors of line edit by setting the palette like :

    QLineEdit *le = new QLineEdit();
    
    QPalette palette;
    palette.setColor(QPalette::Base,Qt::black);
    palette.setColor(QPalette::Text,Qt::white);
    le->setPalette(palette);
    

提交回复
热议问题