IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

ComboBox QML Type

Provides a drop-down list functionality.

This type was introduced in Qt 5.1.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

ComboBox QML Type▲

  • Import Statement: import QtQuick.Controls 1.4

  • Since: Qt 5.1

  • Inherits: FocusScope

  • Group: ComboBox is part of https://

Detailed Description▲

Image non disponible

Add items to the https:// by assigning it a https://, or a list of strings to the https:// property.

 
Sélectionnez
ComboBox {
    width: 200
    model: [ "Banana", "Apple", "Coconut" ]
}

In this example we are demonstrating how to use a https:// with a combo box.

 
Sélectionnez
ComboBox {
    currentIndex: 2
    model: ListModel {
        id: cbItems
        ListElement { text: "Banana"; color: "Yellow" }
        ListElement { text: "Apple"; color: "Green" }
        ListElement { text: "Coconut"; color: "Brown" }
    }
    width: 200
    onCurrentIndexChanged: console.debug(cbItems.get(currentIndex).text + ", " + cbItems.get(currentIndex).color)
}

You can make a combo box editable by setting the https:// property. An editable combo box will autocomplete its text based on what is available in the model.

In the next example we demonstrate how you can append content to an editable combo box by reacting to the https:// signal. Note that you have to explicitly prevent duplicates.

 
Sélectionnez
ComboBox {
    editable: true
    model: ListModel {
        id: model
        ListElement { text: "Banana"; color: "Yellow" }
        ListElement { text: "Apple"; color: "Green" }
        ListElement { text: "Coconut"; color: "Brown" }
    }
    onAccepted: {
        if (find(currentText) === -1) {
            model.append({text: editText})
            currentIndex = find(editText)
        }
    }
}

You can create a custom appearance for a https:// by assigning a https://.

Property Documentation▲

 

[read-only, since QtQuick.Controls 1.1] acceptableInput : bool▲

Returns true if the combo box contains acceptable text in the editable text field.

If a validator was set, this property will return true if the current text satisfies the validator or mask as a final string (not as an intermediate string).

This property was introduced in QtQuick.Controls 1.1.

See Also▲

See also https://, https://

activeFocusOnPress : bool▲

This property specifies whether the combobox should gain active focus when pressed. The default value is false.

[read-only, since QtQuick.Controls 1.1] count : int▲

This property holds the number of items in the combo box.

This property was introduced in QtQuick.Controls 1.1.

currentIndex : int▲

The index of the currently selected item in the https://.

Setting currentIndex to -1 will reset the selection and clear the text label. If https:// is true, you may also need to manually clear https://.

See Also▲

See also https://

[read-only] currentText : string▲

The text of the currently selected item in the https://.

Since currentText depends on currentIndex, there's no way to ensure currentText will be up to date whenever a onCurrentIndexChanged handler is called.

[since QtQuick.Controls 1.1] editText : string▲

This property specifies text being manipulated by the user for an editable combo box.

This property was introduced in QtQuick.Controls 1.1.

[since QtQuick.Controls 1.1] editable : bool▲

This property holds whether the combo box can be edited by the user. The default value is false.

This property was introduced in QtQuick.Controls 1.1.

[read-only] hovered : bool▲

This property indicates whether the control is being hovered.

[read-only, since QtQuick.Controls 1.3] inputMethodComposing : bool▲

This property holds whether an editable https:// has partial text input from an input method.

While it is composing an input method may rely on mouse or key events from the https:// to edit or commit the partial text. This property can be used to determine when to disable events handlers that may interfere with the correct operation of an input method.

This property was introduced in QtQuick.Controls 1.3.

[since QtQuick.Controls 1.5] inputMethodHints : enumeration▲

Provides hints to the input method about the expected content of the combo box and how it should operate.

The value is a bit-wise combination of flags or Qt.ImhNone if no hints are set.

Flags that alter behavior are:

  • Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.

  • Qt.ImhSensitiveData - Typed text should not be stored by the active input method in any persistent storage like predictive user dictionary.

  • Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case when a sentence ends.

  • Qt.ImhPreferNumbers - Numbers are preferred (but not required).

  • Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).

  • Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).

  • Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing.

  • Qt.ImhDate - The text editor functions as a date field.

  • Qt.ImhTime - The text editor functions as a time field.

Flags that restrict input (exclusive flags) are:

  • Qt.ImhDigitsOnly - Only digits are allowed.

  • Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.

  • Qt.ImhUppercaseOnly - Only upper case letter input is allowed.

  • Qt.ImhLowercaseOnly - Only lower case letter input is allowed.

  • Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.

  • Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.

  • Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.

Masks:

  • Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.

This property was introduced in QtQuick.Controls 1.5.

[since QtQuick.Controls 1.3] menu : Component▲

The menu is only in use when https:// is true

This property was introduced in QtQuick.Controls 1.3.

model : model▲

The model to populate the https:// from.

Changing the model after initialization will reset https:// to 0.

[read-only] pressed : bool▲

This property holds whether the button is being pressed.

[since QtQuick.Controls 1.3] selectByMouse : bool▲

This property determines if the user can select the text in the editable text field with the mouse.

The default value is true.

This property was introduced in QtQuick.Controls 1.3.

style : Component▲

The style Component for this control.

See Also▲

See also Qt Quick Controls Styles QML Types

textRole : string▲

The model role used for populating the https://.

[since QtQuick.Controls 1.1] validator : Validator▲

Allows you to set a text validator for an editable https://. When a validator is set, the text field will only accept input which leaves the text property in an intermediate state. The accepted signal will only be sent if the text is in an acceptable state when enter is pressed.

Currently supported validators are https://, https://, and https://. An example of using validators is shown below, which allows input of integers between 11 and 31 into the text field:

This property is only applied when https:// is true

 
Sélectionnez
import QtQuick 2.2
import QtQuick.Controls 1.2

ComboBox {
    editable: true
    model: 10
    validator: IntValidator {bottom: 0; top: 10;}
    focus: true
}

This property was introduced in QtQuick.Controls 1.1.

See Also▲

See also https://, https://, https://

Signal Documentation▲

 

[since QtQuick.Controls 1.1] accepted()▲

This signal is emitted when the Return or Enter key is pressed on an https:// combo box. If the confirmed string is not currently in the model, the https:// will be set to -1 and the https:// will be updated accordingly.

If there is a https:// set on the combobox, the signal will only be emitted if the input is in an acceptable state.

The corresponding handler is onAccepted.

The corresponding handler is onAccepted.

This signal was introduced in QtQuick.Controls 1.1.

[since QtQuick.Controls 1.1] activated(int index)▲

This signal is similar to https:// changed, but will only be emitted if the combo box index was changed by the user, not when set programmatically.

index is the activated model index, or -1 if a new string is accepted.

The corresponding handler is onActivated.

The corresponding handler is onActivated.

This signal was introduced in QtQuick.Controls 1.1.

Method Documentation▲

 

[since QtQuick.Controls 1.1] int find(string text)▲

Finds and returns the index of a given text If no match is found, -1 is returned. The search is case sensitive.

This method was introduced in QtQuick.Controls 1.1.

[since QtQuick.Controls 1.1] void selectAll()▲

Causes all https:// to be selected.

This method was introduced in QtQuick.Controls 1.1.

[since QtQuick.Controls 1.1] string textAt(int index)▲

Returns the text for a given index. If an invalid index is provided, null is returned

This method was introduced in QtQuick.Controls 1.1.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.