QT ComboBox is drawn in a wrong place
QT 5.6.2 on Ubuntu 18.04
I have a very simple ComboBox
import QtQuick.Controls 1.4
Row{//box
Item{width: 0.02 * root.width; height: 1}//space
spacing: 0.02 * root.width
ComboBox{//Recording type
id: typeCombo
anchors.bottom: parent
currentIndex: 2
model: ["TOWING", "PRE_FLIGHT_CHECKS", "FLIGHT"]
width: 0.4 * root.width; height: 0.15 * root.height
}
Rectangle{
id: rectangle
width: 0.5 * root.width; height: 0.15 * root.height
border{color: 'gray'; width: 0.1 * rectangle.height}
radius: 0.18 * rectangle.height
clip: true
onEnabledChanged: if(!enabled) textInput.text = ''
opacity: enabled? 1: 0.3
visible: ddsObject.isRecorderStation
TextInput{
id: textInput
anchors.centerIn: parent
font.pixelSize: 0.6 * rectangle.height
maximumLength: 100
}
MouseArea{
anchors.fill: parent
onPressed: parent.border.color = 'magenta'
onReleased: parent.border.color = 'gray'
onCanceled:{parent.border.color = 'gray'; execute()}
onClicked: execute()
function execute(){textInput.forceActiveFocus(Qt.OtherFocusReason)}
}
}
}
However, when clicked it is drawn at the bottom right corner of the application window. Also there is this message from the framework:
QmlViewGadgetWidget(0x563561aa31e0) must be a top level window
Any ideas how to fix it? I would expect the pull down menu to be drawn right below the ComboBox
element.
Could be related to this question. However, the answer said that the issue was fixed long time ago.
qt qml qt5 qt-quick qt5.6
add a comment |
QT 5.6.2 on Ubuntu 18.04
I have a very simple ComboBox
import QtQuick.Controls 1.4
Row{//box
Item{width: 0.02 * root.width; height: 1}//space
spacing: 0.02 * root.width
ComboBox{//Recording type
id: typeCombo
anchors.bottom: parent
currentIndex: 2
model: ["TOWING", "PRE_FLIGHT_CHECKS", "FLIGHT"]
width: 0.4 * root.width; height: 0.15 * root.height
}
Rectangle{
id: rectangle
width: 0.5 * root.width; height: 0.15 * root.height
border{color: 'gray'; width: 0.1 * rectangle.height}
radius: 0.18 * rectangle.height
clip: true
onEnabledChanged: if(!enabled) textInput.text = ''
opacity: enabled? 1: 0.3
visible: ddsObject.isRecorderStation
TextInput{
id: textInput
anchors.centerIn: parent
font.pixelSize: 0.6 * rectangle.height
maximumLength: 100
}
MouseArea{
anchors.fill: parent
onPressed: parent.border.color = 'magenta'
onReleased: parent.border.color = 'gray'
onCanceled:{parent.border.color = 'gray'; execute()}
onClicked: execute()
function execute(){textInput.forceActiveFocus(Qt.OtherFocusReason)}
}
}
}
However, when clicked it is drawn at the bottom right corner of the application window. Also there is this message from the framework:
QmlViewGadgetWidget(0x563561aa31e0) must be a top level window
Any ideas how to fix it? I would expect the pull down menu to be drawn right below the ComboBox
element.
Could be related to this question. However, the answer said that the issue was fixed long time ago.
qt qml qt5 qt-quick qt5.6
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Qt 5.6 andimport QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?
– TrebuchetMS
Nov 29 '18 at 0:04
add a comment |
QT 5.6.2 on Ubuntu 18.04
I have a very simple ComboBox
import QtQuick.Controls 1.4
Row{//box
Item{width: 0.02 * root.width; height: 1}//space
spacing: 0.02 * root.width
ComboBox{//Recording type
id: typeCombo
anchors.bottom: parent
currentIndex: 2
model: ["TOWING", "PRE_FLIGHT_CHECKS", "FLIGHT"]
width: 0.4 * root.width; height: 0.15 * root.height
}
Rectangle{
id: rectangle
width: 0.5 * root.width; height: 0.15 * root.height
border{color: 'gray'; width: 0.1 * rectangle.height}
radius: 0.18 * rectangle.height
clip: true
onEnabledChanged: if(!enabled) textInput.text = ''
opacity: enabled? 1: 0.3
visible: ddsObject.isRecorderStation
TextInput{
id: textInput
anchors.centerIn: parent
font.pixelSize: 0.6 * rectangle.height
maximumLength: 100
}
MouseArea{
anchors.fill: parent
onPressed: parent.border.color = 'magenta'
onReleased: parent.border.color = 'gray'
onCanceled:{parent.border.color = 'gray'; execute()}
onClicked: execute()
function execute(){textInput.forceActiveFocus(Qt.OtherFocusReason)}
}
}
}
However, when clicked it is drawn at the bottom right corner of the application window. Also there is this message from the framework:
QmlViewGadgetWidget(0x563561aa31e0) must be a top level window
Any ideas how to fix it? I would expect the pull down menu to be drawn right below the ComboBox
element.
Could be related to this question. However, the answer said that the issue was fixed long time ago.
qt qml qt5 qt-quick qt5.6
QT 5.6.2 on Ubuntu 18.04
I have a very simple ComboBox
import QtQuick.Controls 1.4
Row{//box
Item{width: 0.02 * root.width; height: 1}//space
spacing: 0.02 * root.width
ComboBox{//Recording type
id: typeCombo
anchors.bottom: parent
currentIndex: 2
model: ["TOWING", "PRE_FLIGHT_CHECKS", "FLIGHT"]
width: 0.4 * root.width; height: 0.15 * root.height
}
Rectangle{
id: rectangle
width: 0.5 * root.width; height: 0.15 * root.height
border{color: 'gray'; width: 0.1 * rectangle.height}
radius: 0.18 * rectangle.height
clip: true
onEnabledChanged: if(!enabled) textInput.text = ''
opacity: enabled? 1: 0.3
visible: ddsObject.isRecorderStation
TextInput{
id: textInput
anchors.centerIn: parent
font.pixelSize: 0.6 * rectangle.height
maximumLength: 100
}
MouseArea{
anchors.fill: parent
onPressed: parent.border.color = 'magenta'
onReleased: parent.border.color = 'gray'
onCanceled:{parent.border.color = 'gray'; execute()}
onClicked: execute()
function execute(){textInput.forceActiveFocus(Qt.OtherFocusReason)}
}
}
}
However, when clicked it is drawn at the bottom right corner of the application window. Also there is this message from the framework:
QmlViewGadgetWidget(0x563561aa31e0) must be a top level window
Any ideas how to fix it? I would expect the pull down menu to be drawn right below the ComboBox
element.
Could be related to this question. However, the answer said that the issue was fixed long time ago.
qt qml qt5 qt-quick qt5.6
qt qml qt5 qt-quick qt5.6
edited Jan 11 at 1:39
ilya1725
asked Nov 27 '18 at 19:48
ilya1725ilya1725
1,81732440
1,81732440
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Qt 5.6 andimport QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?
– TrebuchetMS
Nov 29 '18 at 0:04
add a comment |
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Qt 5.6 andimport QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?
– TrebuchetMS
Nov 29 '18 at 0:04
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Qt 5.6 and
import QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?– TrebuchetMS
Nov 29 '18 at 0:04
Qt 5.6 and
import QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?– TrebuchetMS
Nov 29 '18 at 0:04
add a comment |
1 Answer
1
active
oldest
votes
You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root
Thank you for the suggestion. MyComboBox
is inside a Row together with an edit boxRectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".
– ilya1725
Nov 27 '18 at 21:55
1
Then, you can set the propertyanchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507081%2fqt-combobox-is-drawn-in-a-wrong-place%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root
Thank you for the suggestion. MyComboBox
is inside a Row together with an edit boxRectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".
– ilya1725
Nov 27 '18 at 21:55
1
Then, you can set the propertyanchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
add a comment |
You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root
Thank you for the suggestion. MyComboBox
is inside a Row together with an edit boxRectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".
– ilya1725
Nov 27 '18 at 21:55
1
Then, you can set the propertyanchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
add a comment |
You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root
You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root
answered Nov 27 '18 at 19:54
xecoxeco
13211
13211
Thank you for the suggestion. MyComboBox
is inside a Row together with an edit boxRectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".
– ilya1725
Nov 27 '18 at 21:55
1
Then, you can set the propertyanchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
add a comment |
Thank you for the suggestion. MyComboBox
is inside a Row together with an edit boxRectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".
– ilya1725
Nov 27 '18 at 21:55
1
Then, you can set the propertyanchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
Thank you for the suggestion. My
ComboBox
is inside a Row together with an edit box Rectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".– ilya1725
Nov 27 '18 at 21:55
Thank you for the suggestion. My
ComboBox
is inside a Row together with an edit box Rectangle
. As a result this message came back: "QML Row: Cannot specify left, right, horizontalCenter, fill, or centerIn anchors for items inside Row. Row will not function".– ilya1725
Nov 27 '18 at 21:55
1
1
Then, you can set the property
anchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
Then, you can set the property
anchors.verticalCenter: parent.verticalCenter
– xeco
Nov 28 '18 at 9:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507081%2fqt-combobox-is-drawn-in-a-wrong-place%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 27 '18 at 19:52
Why using a not supported Qt Version?
– sk2212
Nov 28 '18 at 11:20
Which version is supported? Primarily because I've inherited this code and not created it originally.
– ilya1725
Nov 28 '18 at 18:59
Qt 5.6 and
import QtQuick.Controls 1.4
I wouldn't say it's entirely unsupported. But there's Qt 5.11 and QtQuick Controls 2.x now. Even though the code isn't originally yours, maybe think about upping it to that?– TrebuchetMS
Nov 29 '18 at 0:04