Results 1 to 6 of 6

Thread: locking the combobox

  1. #1
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default locking the combobox

    Is there a way to lock the combobox, rather like disabling, but not changing colors. I want the box to appear active but not let the current item change. I don't care whether the listbox shows or not, I just don't want it to change. Is this possible?

    Thanks!

    Jay

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: locking the combobox

    You can remove all items from the combobox. It'll not be possible to change it then. Another way you could try is to connect the textChanged() signal (or activated() -- it should work the same) to a custom slot and make it change the item back to the one that should be selected. Although a normal behaviour is just to disable a widget that can't be used... Third way is to install an event filter on the combobox and filter out all mouse press events not letting them pass to the regular QComboBox mousePressEvent handler.

  3. The following user says thank you to wysota for this useful post:

    jayw710 (1st April 2006)

  4. #3
    Join Date
    Apr 2006
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: locking the combobox

    Sure just "reset" the list box to what ever its original state after the user tries to make a change.
    #
    # Make install
    # ! mutants
    #

  5. The following user says thank you to Protocol for this useful post:

    jayw710 (1st April 2006)

  6. #4
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Re: locking the combobox

    I was hoping there was a simple function call, but these are both good solutions. Thanks!

    Jay

  7. #5
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: locking the combobox

    The way I did it is disabling it, but setting the "disabled" pallette properties of the combobox to the same as the "active" combobox.

  8. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: locking the combobox

    @SK
    Did you use setColorGroup() for that?
    I have a similar problem and I tried the same thig but it doesnt work for me, am not sure why.
    If I use setColorGroup() with QPalette::Inactive, and specify each color role, then set that pallete to my widget, when it gets disabled it just uses its normal disabled colors...
    My actual problem is that I want to get rid of a text shadow in the disabled mode...
    If you could post your code regarding this I would really appreciate it!
    Qt Code:
    1. //current color group is active (this is in the constructor)
    2. QPalette p = this->palette();
    3. p.setColorGroup(QPalette::Disabled,p.windowText(),p.button(),p.light(),p.dark(),p.mid(),p.text(),p.brightText(),p.base(),p.window());
    4. setPalette(p);
    To copy to clipboard, switch view to plain text mode 
    Thanks.

Similar Threads

  1. Combobox with checkable items
    By qtneuling in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2008, 14:42
  2. ComboBox of bmp:s
    By SailinShoes in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2008, 15:22
  3. [Qt 4.3.1]A problem with combobox style
    By Tamara in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2007, 10:49
  4. Combobox Signals
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2006, 10:21
  5. Filling combobox from database
    By Philip_Anselmo in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2006, 17:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.