In this project the customised combo Box action linked with
Text widget of the Flipabit.
Steps in Customised ComboBox:
- Open a new project: File > New
- Add new Component: Widgets>Component>Create new
- Add Text Widget : Widgets> T Text
(Name it as Txt in Widget Tree and Change Text properties in Font in Widget Inspector) - Add Code to the Component 1.
Select Component 1 in Widget Tree > Click on Actions (<> Actions)> Click on Code icon(# Code) in the main menu bar - Paste Code in the Code Editor: 4th step action opens
code Editor window> Click + icon > Click cursor beside 1
in editor> Paste the Copied code in the edotor. - Save the Code: Click on the Page > In the pop up window
click on Yes Button. - Run the project: Run>Preview
The code for ComboBox in QML:
import QtQuick 2.15
import QtQuick.Controls 2.15
Item{
ComboBox {
id: comboBox
width: 200
model: [“Option 0”,“Option 1”, “Option 2”, “Option 3” ,“Option 4”, “Option 5”, “Option 6”,“Option 7”, “Option 8”,“Option 9”,“Option 10”, “Option 11”, “Option 12”]
onCurrentTextChanged: {
document.childByName(“Txt”).content.scriptAdaptor.actionSetText("Index : “+ comboBox.currentIndex +”
"+ "Text : "+ comboBox.currentText)
}
}
}
ComboBox Customised with Text Widget.flp (5.8 KB)