Qml ComboBox with TextField in Popup
up vote
2
down vote
favorite
I have created a custom ComboBox that uses a ListView with a TextField in the footer, that's used to dynamically add options to the ComboBox.
The problem is, that as soon as the popup loses focus (so when the TextField receives focus), the popup gets closed.
I tried to force the popup to stay open, which does work, but then prevents the TextField from receiving focus (I guess because the popup regains focus as soon as open() is called).
ComboBox {
// ...
popup: Popup {
property bool forceOpen: false
onClosed: {
if(forceOpen)
open()
}
contentItem: ListView {
// ...
footer: TextField {
onPressed: forceOpen = true
}
}
}
}
I also tried all values for the closePolicy property of the Popup, but none of them helped.
I am using Qt5.11. The forceOpen solution used to work with Qt 5.10, but does not anymore.
qt combobox popup qml qcombobox
add a comment |
up vote
2
down vote
favorite
I have created a custom ComboBox that uses a ListView with a TextField in the footer, that's used to dynamically add options to the ComboBox.
The problem is, that as soon as the popup loses focus (so when the TextField receives focus), the popup gets closed.
I tried to force the popup to stay open, which does work, but then prevents the TextField from receiving focus (I guess because the popup regains focus as soon as open() is called).
ComboBox {
// ...
popup: Popup {
property bool forceOpen: false
onClosed: {
if(forceOpen)
open()
}
contentItem: ListView {
// ...
footer: TextField {
onPressed: forceOpen = true
}
}
}
}
I also tried all values for the closePolicy property of the Popup, but none of them helped.
I am using Qt5.11. The forceOpen solution used to work with Qt 5.10, but does not anymore.
qt combobox popup qml qcombobox
1
This might be a bit of a weird question but why not to useComboBoxinstead of creating the custom one?
– folibis
Nov 6 at 10:10
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have created a custom ComboBox that uses a ListView with a TextField in the footer, that's used to dynamically add options to the ComboBox.
The problem is, that as soon as the popup loses focus (so when the TextField receives focus), the popup gets closed.
I tried to force the popup to stay open, which does work, but then prevents the TextField from receiving focus (I guess because the popup regains focus as soon as open() is called).
ComboBox {
// ...
popup: Popup {
property bool forceOpen: false
onClosed: {
if(forceOpen)
open()
}
contentItem: ListView {
// ...
footer: TextField {
onPressed: forceOpen = true
}
}
}
}
I also tried all values for the closePolicy property of the Popup, but none of them helped.
I am using Qt5.11. The forceOpen solution used to work with Qt 5.10, but does not anymore.
qt combobox popup qml qcombobox
I have created a custom ComboBox that uses a ListView with a TextField in the footer, that's used to dynamically add options to the ComboBox.
The problem is, that as soon as the popup loses focus (so when the TextField receives focus), the popup gets closed.
I tried to force the popup to stay open, which does work, but then prevents the TextField from receiving focus (I guess because the popup regains focus as soon as open() is called).
ComboBox {
// ...
popup: Popup {
property bool forceOpen: false
onClosed: {
if(forceOpen)
open()
}
contentItem: ListView {
// ...
footer: TextField {
onPressed: forceOpen = true
}
}
}
}
I also tried all values for the closePolicy property of the Popup, but none of them helped.
I am using Qt5.11. The forceOpen solution used to work with Qt 5.10, but does not anymore.
qt combobox popup qml qcombobox
qt combobox popup qml qcombobox
edited Nov 6 at 12:28
asked Nov 5 at 17:46
Johannes Stricker
12119
12119
1
This might be a bit of a weird question but why not to useComboBoxinstead of creating the custom one?
– folibis
Nov 6 at 10:10
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28
add a comment |
1
This might be a bit of a weird question but why not to useComboBoxinstead of creating the custom one?
– folibis
Nov 6 at 10:10
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28
1
1
This might be a bit of a weird question but why not to use
ComboBox instead of creating the custom one?– folibis
Nov 6 at 10:10
This might be a bit of a weird question but why not to use
ComboBox instead of creating the custom one?– folibis
Nov 6 at 10:10
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Your problem should be fixed if you do not accept the focus on the ComboBox:
ComboBox {
focusPolicy: Qt.NoFocus
popup: Popup {
// ...
}
}
Awesome, that really solved the problem. And it doesn't even require the messy workaround with aforceOpenproperty. Thanks!
– Johannes Stricker
Nov 7 at 6:42
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Your problem should be fixed if you do not accept the focus on the ComboBox:
ComboBox {
focusPolicy: Qt.NoFocus
popup: Popup {
// ...
}
}
Awesome, that really solved the problem. And it doesn't even require the messy workaround with aforceOpenproperty. Thanks!
– Johannes Stricker
Nov 7 at 6:42
add a comment |
up vote
1
down vote
accepted
Your problem should be fixed if you do not accept the focus on the ComboBox:
ComboBox {
focusPolicy: Qt.NoFocus
popup: Popup {
// ...
}
}
Awesome, that really solved the problem. And it doesn't even require the messy workaround with aforceOpenproperty. Thanks!
– Johannes Stricker
Nov 7 at 6:42
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Your problem should be fixed if you do not accept the focus on the ComboBox:
ComboBox {
focusPolicy: Qt.NoFocus
popup: Popup {
// ...
}
}
Your problem should be fixed if you do not accept the focus on the ComboBox:
ComboBox {
focusPolicy: Qt.NoFocus
popup: Popup {
// ...
}
}
answered Nov 6 at 14:08
augre
671312
671312
Awesome, that really solved the problem. And it doesn't even require the messy workaround with aforceOpenproperty. Thanks!
– Johannes Stricker
Nov 7 at 6:42
add a comment |
Awesome, that really solved the problem. And it doesn't even require the messy workaround with aforceOpenproperty. Thanks!
– Johannes Stricker
Nov 7 at 6:42
Awesome, that really solved the problem. And it doesn't even require the messy workaround with a
forceOpen property. Thanks!– Johannes Stricker
Nov 7 at 6:42
Awesome, that really solved the problem. And it doesn't even require the messy workaround with a
forceOpen property. Thanks!– Johannes Stricker
Nov 7 at 6:42
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53159560%2fqml-combobox-with-textfield-in-popup%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
This might be a bit of a weird question but why not to use
ComboBoxinstead of creating the custom one?– folibis
Nov 6 at 10:10
Of, ofcourse I am using a regular ComboBox, I edited the entry post.
– Johannes Stricker
Nov 6 at 12:28