Results 1 to 9 of 9

Thread: QComboBox does not update

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QComboBox does not update

    Hi.

    I have a QComboBox on my gui that I use to select a string from a given set of options. When I click on it the dropdown appears, I make my choice and then the dropdown closes again, but it's still the default value that is displayed. The combo box is connected to a slot, so I know that the choice was made correctly. Only when I move the mouse over the combo it finally gets updated and shows the last choice made.

    I also tried connecting it to its own update slot

    Qt Code:
    1. connect(ui.portComboBox, SIGNAL(currentIndexChanged(const QString)), ui.portComboBox, SLOT(update()));
    To copy to clipboard, switch view to plain text mode 

    to no avail.

    Should I program something that automatically moves the mouse over the combo when a choice was made or what?

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox does not update

    could u show some more code related to this?

  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox does not update

    Not really. I created the QComboBox in Designer. I checked the properties, there is nothing related to how the combo box is updated. Other than that, I just take the reference from ui and connect the combo to something:

    Qt Code:
    1. connect(ui.portComboBox, SIGNAL(currentIndexChanged(const QString)), &robotInterface, SLOT(setPortName(const QString)));
    To copy to clipboard, switch view to plain text mode 

    That's how I see that the selection was successfully made.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QComboBox does not update

    you need to populate combobox by yourself or set a model which will take care about updating combobox.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QComboBox does not update

    For a better understanding. You have a QComboBox with values 1 (default), 2, 3, 4, 5, 6, 7, 8.... Use case:

    1 is shown
    -> you select 4
    1 is still shown (but 4 is "emitted")
    -> mouse over
    4 is shown
    -> you select 6
    ??? what is shown 4 or 1 (the default)

    Is this behavior also if you use the preview function in designer?

  6. #6
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox does not update

    If you select 6, 4 is still shown. It keeps the old selection until you move over it with the mouse and then it refreshes.

    The Designer preview does it just like it should. Well it did while I had the values hardcoded in the ui file. Now I changed it according to jpn's suggestion like this:

    Qt Code:
    1. ui.portComboBox->addItems(QStringList() << "COM1" << "COM2" << "COM3" << "COM4");
    To copy to clipboard, switch view to plain text mode 

    But it still shows exactly the same behavious. I have to create a model for this little thing now? Argh.

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QComboBox does not update

    I guess if it works in the designer and in your application not, you must do something - what ever - in your application which is blocking the normal update of the combobox...

  8. #8
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox does not update

    How could that possibly be? There is nothing related to this combo, other than its signal being connected to the slot of an object. Nothing is accessing or changing the combo in any way. Other inputs in the same widget, like a QTextEdit and some QLineEdits update perfectly fine.

    I use the Eclipse Integration of Designer and closed the Property Editor by accident. How do I get it back?

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QComboBox does not update

    Quote Originally Posted by Cruz View Post
    How could that possibly be? There is nothing related to this combo, other than its signal being connected to the slot of an object. Nothing is accessing or changing the combo in any way. Other inputs in the same widget, like a QTextEdit and some QLineEdits update perfectly fine.
    Don't ask me

    Quote Originally Posted by Cruz View Post
    I use the Eclipse Integration of Designer and closed the Property Editor by accident. How do I get it back?
    Window -> Show View -> Others :: Qt -> Qt C++ Property Editor

Similar Threads

  1. Qcombobox isModified method
    By tgreaves in forum Qt Programming
    Replies: 3
    Last Post: 7th January 2009, 23:12
  2. Qt Update project - Opinions wanted
    By pvdk in forum Qt Programming
    Replies: 0
    Last Post: 8th November 2008, 08:41
  3. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  4. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  5. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14

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.