[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Problems when adding a combo box to a toolbar and KActionCollection in KF6
From: Nicolas Fella <nicolas.fella () gmx ! de>
Date: 2023-10-30 0:11:27
Message-ID: 6526eecf-622d-4b1b-9fb5-1d13a98d3c72 () gmx ! de
[Download RAW message or body]
On 10/29/23 18:38, Stefano Crocco wrote:
> Hello to everyone,
> while porting Konqueror to KF6, I've hit a problem I don't know how to solve.
> The issue is that it's impossible to give focus to the location bar by
> clicking on it with the mouse as you can do in KF5.
>
> After spending some hours trying to find out the cause of this, I reached the
> conclusion that it has something to do with the main window's
> actionCollection. A shortened version of the code which creates the location
> bar is the following:
>
> KonqMainWindow::KonqMainWindow() : KParts::MainWindow()
> {
> //...
> m_combo = new KonqCombo(nullptr) //KonqCombo derives from KHistoryComboBox
> //...
> QWidgetAction *comboAction = new QWidgetAction(this);
> actionCollection()->addAction(QStringLiteral("toolbar_url_combo"),
> comboAction);
> comboAction->setDefaultWidget(m_combo);
> //...
> setXMLFile(QStringLiteral("konqueror.rc"));
> createGUI(nullptr);
>
> //"locationToolBar" is the name of the toolbar where the widget should be
> //inserted
> m_combo->setParent(toolBar(QStringLiteral("locationToolBar")));
> m_combo->show();
> //...
> }
>
> If I remove the addAction method, the location bar is, of course, displayed
> floating above the toolbar and it can be given focus clicking on it with the
> mouse. The same happens if I remove the setDefaultWidget line. I tried adding
> the action to the toolbar using
>
> QAction *a = toolBar(QStringLiteral("locationToolBar"))->addWidget(m_combo);
> actionCollection()->addAction(QStringLiteral("toolbar_url_combo"), a);
>
> This gives the same problem as the previous code; however, if I remove the
> second line, the focus works correctly again. This is what made me suppose the
> problem is related to KActionCollection.
>
> Initially, I thought that the problem was caused by some event filter or event
> handler, so I tried creating a different action with new QComboBox, new action
> name and so on, but the results were the same. Also, using a QLineEdit instead
> of a QComboBox changed nothing.
>
> I tried looking at the source code of KActionCollection, but I couldn't find
> any significant difference between the KF5 and the KF6 version. The same can be
> said for Konqueror source code, however.
>
> Can someone give me some hints about what's happening?
>
> Thanks in advance
>
> Stefano
Hi,
focus and toolbar brings
https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/188 to my
mind. Can you check whether it works as you expect before that change?
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic