Important: Please read the Qt Code of Conduct -

Ignore pushbutton when using focusWidget()

  • I have several listwidgets filled with items. And everytime you select an item, that item will then be copied to another listwidget.
    Now I can easily do this with a doubleclick. But I would really like to use a button for it. But everytime I then use that button, that button will then become the focussed widget instead of a listwidget. And I need to use focuswidget in order to manage what listwidget the user is currently controlling (or else you can first click on an item in one listwidget then an item in another and then when you click add it will add from both listwidgets (or chrash))
    Any suggestions on how to avoid this is greatly appreciated.

  • I guess I am doomed then.

  • Moderators

    Well, you're only doomed if you are impatient. You posted your question on a Saturday, when a lot of people are not online checking the forums, and it's only Monday now. I'd say it should be reasonable to give people a little more time before jumping in with the doom and gloom. We are all volunteers here who answer questions on our own time.

    In regards to your question, what about if when either of your list widgets obtain focus, they could set a member variable to a specific value to indicate which list has been focused last. Then upon your button press you could query that member variable to determine which listwidget to query.

  • Exactly what I did to overcome my issue. It just seems like such a hassle, since I have a loooot af listWidgets. I believe QT need a previousWidget() function just as it has a previousItem(). But that is just me.
    And yes I will try to be more patient. I just hate it when I get stuck in one of my projects. xD

  • Moderators

    You might also look into maybe some magic with setFocusProxy(). Haven't really thought it through, but there might be something that could be made to work.

Log in to reply