Qt6 topics merged with General

[Solved] setting a stylesheet on QTextEdit also modifies its context menu - how to preserve context menu style?

  • I'm trying to set a stylesheet on a QTextEdit box to give it a black background with white text. The code below works but it also changes the background of the context menu in the QTextEdit box. How can I preserve the style of the context menu while also changing the background color of the QTextEdit box?
    box = new QTextEdit;
    box->setStyleSheet("background: #000000; color: #ffffff");

  • Try to set
    QTextEdit {background: #000000; color: #ffffff;}

  • That fixed it! Thanks for the tip.

Log in to reply