QT ComboBox is drawn in a wrong place












-1















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.










share|improve this question

























  • 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


















-1















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.










share|improve this question

























  • 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
















-1












-1








-1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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





















  • 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



















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














1 Answer
1






active

oldest

votes


















0














You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root






share|improve this answer
























  • 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





    Then, you can set the property anchors.verticalCenter: parent.verticalCenter

    – xeco
    Nov 28 '18 at 9:15













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
});


}
});














draft saved

draft discarded


















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









0














You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root






share|improve this answer
























  • 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





    Then, you can set the property anchors.verticalCenter: parent.verticalCenter

    – xeco
    Nov 28 '18 at 9:15


















0














You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root






share|improve this answer
























  • 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





    Then, you can set the property anchors.verticalCenter: parent.verticalCenter

    – xeco
    Nov 28 '18 at 9:15
















0












0








0







You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root






share|improve this answer













You need to anchor ComboBox to your root component. You can achieve this by setting the property anchors.centerIn: root







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '18 at 19:54









xecoxeco

13211




13211













  • 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





    Then, you can set the property anchors.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






  • 1





    Then, you can set the property anchors.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






















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)