Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to make a combo box read only
Qt 6.12 LTS is out! See what's new in the release blog

how to make a combo box read only

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 9 Posters 9.4k 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.
  • K KevDev

    @JonB has half of it. If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.

    SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #5

    Hi,

    @KevDev said in how to make a combo box read only:

    If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.

    How is that related to the question at hand ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    mrjjM 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      @KevDev said in how to make a combo box read only:

      If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.

      How is that related to the question at hand ?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @SGaist
      Hi
      Its to avoid the faded text effect
      when set to disabled which makes it hard to read on some platforms

      alt text
      versus

      alt text
      (setting color in style sheet)

      SGaistS 1 Reply Last reply
      1
      • mrjjM mrjj

        @SGaist
        Hi
        Its to avoid the faded text effect
        when set to disabled which makes it hard to read on some platforms

        alt text
        versus

        alt text
        (setting color in style sheet)

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @mrjj

        Ha ! I misunderstood that part.

        That's usually a bad idea to keep things as normal when disabled.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        mrjjM 1 Reply Last reply
        1
        • SGaistS SGaist

          @mrjj

          Ha ! I misunderstood that part.

          That's usually a bad idea to keep things as normal when disabled.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @SGaist
          Yep, i only guessed as i had some bug reports from user complaining it was hard to read :)

          Totally agree as it violates the visual clues for being Disabled but can be used to adjust the contrast
          to the background as it can be hard to read on some system where they did alter the screen settings for contrast etc.

          1 Reply Last reply
          2
          • S Offline
            S Offline
            stokito
            wrote on last edited by
            #9

            Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented

            SGaistS JonBJ 2 Replies Last reply
            0
            • S stokito

              Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @stokito said in how to make a combo box read only:

              Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented

              Hi,

              What would read-only mean ? The user cannot interact with the widget ? Then setEnabled/setDisabled are already there.
              There's no need for a modified property. QComboBox already provides APIs that signals a change happened.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • S stokito

                Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #11

                @stokito
                As @SGaist says. What does "ReadOnly" here mean to you, and what is "Modified" about?
                For read-only, do you perchance mean setEditable(false)? That is for the user to be able edit/insert items into the combobox choices. But that is the default anyway.

                S 1 Reply Last reply
                0
                • JonBJ JonB

                  @stokito
                  As @SGaist says. What does "ReadOnly" here mean to you, and what is "Modified" about?
                  For read-only, do you perchance mean setEditable(false)? That is for the user to be able edit/insert items into the combobox choices. But that is the default anyway.

                  S Offline
                  S Offline
                  Scott Aron Bloom
                  wrote on last edited by
                  #12

                  @JonB I have come across this many times.

                  There is a reason lineedits, plain text, spin boxes etc etc have a read only.

                  You want to present the data as normal, but not allow the user to change it.

                  A good example, say your app has two types of users, "admins" and "viewers". They both can look at the same exact record shown in a dialog.

                  That dialog's inner widget which has all the functionality, is then used to print the report, (rendering the dialog to a printer).

                  The admin can edit, the user can not. But they both can print.

                  JonBJ 1 Reply Last reply
                  0
                  • S Scott Aron Bloom

                    @JonB I have come across this many times.

                    There is a reason lineedits, plain text, spin boxes etc etc have a read only.

                    You want to present the data as normal, but not allow the user to change it.

                    A good example, say your app has two types of users, "admins" and "viewers". They both can look at the same exact record shown in a dialog.

                    That dialog's inner widget which has all the functionality, is then used to print the report, (rendering the dialog to a printer).

                    The admin can edit, the user can not. But they both can print.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #13

                    @Scott-Aron-Bloom said in how to make a combo box read only:

                    There is a reason lineedits, plain text, spin boxes etc etc have a read only.

                    Yes, but the question here was specifically about a combobox. And what the poster meant by "read-only" for that, as there are several possibilities, particularly concerning the associated dropdown list. In any case, that poster may well be looking for setEditable(false).

                    1 Reply Last reply
                    1
                    • Joe von HabsburgJ Offline
                      Joe von HabsburgJ Offline
                      Joe von Habsburg
                      wrote on last edited by
                      #14

                      Uncheck editable option on .ui file

                      image.png

                      1 Reply Last reply
                      0

                      • Login

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