Results 1 to 7 of 7

Thread: prevent selection in QComboBox.

  1. #1
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default prevent selection in QComboBox.

    hello,
    how to select an element in a QComboBox programatically and prevent users from changing the selection, whithout setting the QComboBox desabled.
    thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: prevent selection in QComboBox.

    I'd say that preventing the selection from changing without disabling the combo box will just confuse your users. Adding a non-selectable item amongst other selectable items is a different story.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: prevent selection in QComboBox.

    actually, the QComboBox is in a dialog box used in diffirent situations, and sometimes I would really give a unique choice to prevent errors.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: prevent selection in QComboBox.

    It's hard to suggest anything concrete with this amount of background information, but have you considered any other UI components for solving the problem? You know, there are many ways to express "selection", perhaps combo box isn't the best possible choice in this case. Many times this is the case when one has to start customizing functionality of readily available widgets. In worst case the widget loses its intuitivity...
    J-P Nurmi

  5. #5
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: prevent selection in QComboBox.

    have you considered any other UI components for solving the problem? You know, there are many ways to express "selection"
    the component here is constraint by the available dialog box space => QComboBox is suitable ?
    this is the case when one has to start customizing functionality of readily available widgets
    that's the case.
    thanks.

  6. #6
    Join Date
    Apr 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: prevent selection in QComboBox.

    You could set a custom model for your combo box. Then you can return the appropriate flags.

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: prevent selection in QComboBox.

    Quote Originally Posted by hicpalm View Post
    the component here is constraint by the available dialog box space => QComboBox is suitable ?
    Ok, let's say it is. But combo box is also a well known and widely accepted UI component. People expect it to behave in a certain way. What's the problem with disabling it? That's the normal way of preventing selection... But making it semi-disabled in the sense that you can pop up the view but you still can't change the selection will most likely just confuse end-users, because that's not what people are used to.

    Quote Originally Posted by louis_xx View Post
    You could set a custom model for your combo box. Then you can return the appropriate flags.
    Sure it's possible. There's a solution somewhere on this forum. But the question is... is it really a sensible thing to do?
    J-P Nurmi

Similar Threads

  1. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  2. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14
  3. QcomboBox items
    By therealjag in forum Newbie
    Replies: 5
    Last Post: 27th March 2006, 08:21

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.