Colour and appearance of QComboBox
-
Hi all,
One of my forms contains a number of QComboBoxes, as shown below:
When the programme is running, I would like to draw the user's attention to the need to intervene in this group of QComboBoxes by highlighting them, as shown below :
with the following code :
else if (cboMatrix.at(0).at(i)->currentText().left(1) == "A") { //cboMatrix.at(14).at(i)->setStyleSheet(QColor(Qt::red)); cboMatrix.at(14).at(i)->setCurrentIndex(0); cboMatrix.at(14).at(i)->setStyleSheet("color: blue; background-color: yellow;"); cboMatrix.at(15).at(i)->setCurrentIndex(0); cboMatrix.at(15).at(i)->setStyleSheet("color: black; background-color: yellow;"); cboMatrix.at(16).at(i)->setCurrentIndex(0); cboMatrix.at(16).at(i)->setStyleSheet("color: black; background-color: yellow;"); }
Once the user has done this, I'd like to restore the original colours and, above all, make the QcomboBoxes reappear in their normal appearance.
But I've only managed to produce the unsatisfactory result below:with the following code:
// Rétablissement couleurs des colonnes 35, 36, 37 if (lostFocusControl == cboMatrix.at(14).at(i)) { cboMatrix.at(14).at(i)->setStyleSheet("color: white; background-color: black;"); } if (lostFocusControl == cboMatrix.at(15).at(i)) { cboMatrix.at(15).at(i)->setStyleSheet("color: white; background-color: black;"); } if (lostFocusControl == cboMatrix.at(16).at(i)) { cboMatrix.at(16).at(i)->setStyleSheet("color: white; background-color: black;"); }t
Thank you for your opinion on what needs to be done for a much better result.
-
@MortyMars said in Colour and appearance of QComboBox:
I'd like to go back to the way things were
But how did you get there? Is this style your system default?
Do you have a global stylesheet file?
Try
cboMatrix.at(14).at(i)->setStyleSheet("");
It will reset the local stylesheet for this combobox.
-
@MortyMars said in Colour and appearance of QComboBox:
make the QcomboBoxes reappear in their normal appearance.
What is the "normal" appearance? Just set this stylesheet again.
I don't see any comboBox in the first image?! The widget with the blue controls are
QSpinBoxes
right?
So what is the style you had before making theQComboBox
yellow? -
Hi @Pl45m4
Thank you for your interest in my problem :-)@Pl45m4 said in Colour and appearance of QComboBox:
What is the "normal" appearance? Just set this stylesheet again.
The normal appearance is that of the first image
I don't see any comboBox in the first image?! The widget with the blue controls are
QSpinBoxes
right?These are QComboBoxes, but I've reduced the width to a minimum for the purposes of the application.
So what is the style you had before making the
QComboBox
yellow?It's the one in the first image... :
I'd like to go back to the way things were...
Is there a code for system colors ?And above all, how can I restore the outline of the QComboBoxes?
Thank you in advance -
@MortyMars said in Colour and appearance of QComboBox:
I'd like to go back to the way things were
But how did you get there? Is this style your system default?
Do you have a global stylesheet file?
Try
cboMatrix.at(14).at(i)->setStyleSheet("");
It will reset the local stylesheet for this combobox.
-
@Pl45m4 said in Colour and appearance of QComboBox:
cboMatrix.at(14).at(i)->setStyleSheet("")
Thank you @Pl45m4
'cboMatrix.at(14).at(i)->setStyleSheet("");' causes the application to crash, but
'cboMatrix.at(14).at(i)->setStyleSheet("space ");' works as I expect.Your suggestion solves my problem perfectly :-)
-
M MortyMars has marked this topic as solved on