summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2025-09-12 12:31:23 +0200
committerMichal Klocek <michal.klocek@qt.io>2025-11-06 21:53:26 +0000
commitbdc6f81e30bf385c46e4e224b3c54139dc636c9a (patch)
tree1cff3c066f00bb80ad2e5338b2cdbedbdf9ae939
parent2d4bb691635684759a8fbeeba374d67547b6bf30 (diff)
Fix wrong indexing for webenigneview in quicknanobrowser
Code wrongly assumed index of tab bar buttons is fixed. However tab buttons are simply a list and not a dictionary, so index changes on any list update. Use simply a binding to get correct tab button index. This amends ba883b698bc98819de114f1af6f9efc70662ee19. Pick-to: 6.10 6.9 Fixes: QTBUG-139461 Change-Id: I95a30d12ccc954f92895b76cea9948494189b8b1 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r--examples/webenginequick/quicknanobrowser/BrowserWindow.qml6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/webenginequick/quicknanobrowser/BrowserWindow.qml b/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
index 4373223fa..c8efa3969 100644
--- a/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
@@ -18,7 +18,6 @@ ApplicationWindow {
required property ApplicationRoot applicationRoot
property WebEngineView currentWebView: tabBar.currentIndex < tabBar.count ? tabLayout.children[tabBar.currentIndex] : null
property int previousVisibility: Window.Windowed
- property int createdTabs: 0
property bool lastTabClosing: false
width: 1300
@@ -524,8 +523,9 @@ ApplicationWindow {
Component.onCompleted: createTab(win.applicationRoot.defaultProfilePrototype.instance())
function createTab(profile, focusOnNewTab = true, url = undefined) {
- var webview = tabComponent.createObject(tabLayout, {index: tabBar.count , profile: profile});
+ var webview = tabComponent.createObject(tabLayout, {profile: profile});
var newTabButton = tabButtonComponent.createObject(tabBar, {tabTitle: Qt.binding(function () { return webview.title; })});
+ webview.index = Qt.binding(function () { return newTabButton.TabBar.index; })
tabBar.addItem(newTabButton);
if (focusOnNewTab) {
tabBar.setCurrentIndex(tabBar.count - 1);
@@ -554,7 +554,7 @@ ApplicationWindow {
id: tabComponent
WebEngineView {
id: webEngineView
- property int index;
+ property int index: 0
focus: true
onLinkHovered: function(hoveredUrl) {