Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Colour and appearance of QComboBox
Forum Updated to NodeBB v4.3 + New Features

Colour and appearance of QComboBox

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 278 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MortyMarsM Offline
    MortyMarsM Offline
    MortyMars
    wrote on last edited by
    #1

    Hi all,

    One of my forms contains a number of QComboBoxes, as shown below:
    Capture d’écran 2024-04-27 à 18.36.21.jpg

    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 :

    Capture d’écran 2024-04-27 à 18.36.41.jpg

    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:

    Capture d’écran 2024-04-27 à 18.37.21.jpg

    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.

    Pl45m4P 1 Reply Last reply
    0
    • MortyMarsM MortyMars

      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... :

      Capture d’écran 2024-04-27 à 18.36.21.jpg

      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

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #4

      @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.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      MortyMarsM 1 Reply Last reply
      0
      • MortyMarsM MortyMars

        Hi all,

        One of my forms contains a number of QComboBoxes, as shown below:
        Capture d’écran 2024-04-27 à 18.36.21.jpg

        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 :

        Capture d’écran 2024-04-27 à 18.36.41.jpg

        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:

        Capture d’écran 2024-04-27 à 18.37.21.jpg

        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.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #2

        @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 the QComboBox yellow?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        MortyMarsM 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @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 the QComboBox yellow?

          MortyMarsM Offline
          MortyMarsM Offline
          MortyMars
          wrote on last edited by
          #3

          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... :

          Capture d’écran 2024-04-27 à 18.36.21.jpg

          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

          Pl45m4P 1 Reply Last reply
          0
          • MortyMarsM MortyMars

            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... :

            Capture d’écran 2024-04-27 à 18.36.21.jpg

            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

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by
            #4

            @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.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            MortyMarsM 1 Reply Last reply
            0
            • Pl45m4P Pl45m4

              @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.

              MortyMarsM Offline
              MortyMarsM Offline
              MortyMars
              wrote on last edited by
              #5

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

              1 Reply Last reply
              1
              • MortyMarsM MortyMars has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved