I was playing around with the Qt demo browser example mentioned here and noticed an anomaly when I tried making a minor change to the bookmark handling code.
My intention was to make the bookmarks in the toolbar open up in a new tab instead of the existing tab. It works perfectly for the bookmarks that are located directly on the bookmarks tab. But the bookmarks inside a folder are the ones which are behaving weirdly.
I modified the BookmarksToolBar::activated
SLOT
in the bookmarks.cpp to open the url in a new tab instead of existing tab. That's when I noticed that the SLOT
is being called multiple times, the count being equal to the number of times the menu is rendered. i.e, the first time a menu item is activated, the SLOT
is called once, the next time an item is activated, the SLOT
gets called twice and so on.
I thought there must have been multiple signal-slot connections and thus I checked on the BookmarksToolBar::build()
method where the signal-slot connection is done and found that the control flow enters the method only once. I am finding it hard to figure out how the SLOT
is being called multiple times.
The project is question is an example project 'Tab browser' which comes with Qt and can be accessed by clicking on 'Examples' on the Qt-Creator welcome screen. Thus I did not post any source code here.
Any guidance or help in understanding the cause for this anomaly and possible solutions to fix it would be appreciated.