Skip to content

Instantly share code, notes, and snippets.

@mchaput
Created October 1, 2024 21:54
Show Gist options
  • Save mchaput/2b250aed719c1fd1048ac3d153f33989 to your computer and use it in GitHub Desktop.
Save mchaput/2b250aed719c1fd1048ac3d153f33989 to your computer and use it in GitHub Desktop.
Minimal example of issue where Qt labs Menu element gets an extra "AutoFill" submenu if it's in the same window as a TextField
import QtQuick
import QtQuick.Controls
import Qt.labs.platform as Labs
ApplicationWindow {
id: root
width: 640
height: 64
visible: true
Rectangle {
Column {
TextField {
id: textfield
height: 24
text: ""
placeholderText: "Type to search tools"
font.pixelSize: 18
focus: true
background: Rectangle {
color: "transparent"
}
Keys.onEscapePressed: {
root.close()
}
onAccepted: {
print("Selected")
root.close()
}
}
Row {
id: toolbar
Button {
id: menuButton
text: "Menu"
onClicked: {
testMenu.open(menuButton)
}
}
Labs.Menu {
id: testMenu
Labs.MenuItem {
text: qsTr("First")
shortcut: StandardKey.ZoomIn
}
Labs.MenuItem {
text: qsTr("Second")
shortcut: StandardKey.ZoomOut
}
Labs.Menu {
title: "Submenu"
Labs.MenuItem {
text: qsTr("Subitem 1")
shortcut: StandardKey.ZoomOut
}
Labs.MenuItem {
text: qsTr("Subitem 2")
shortcut: StandardKey.ZoomOut
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment