Unsolved QML Dialog dont fit content
-
Hi, I'm trying to do a settings dialog for my app, I'm using extern item that I wrote it, kind following OO orientation on my QML code. But even adding width and height on the extern files, when I load the dialog, it loads small. From the documentation, it says that the QML Dialog should resize to fit the content, but that don't happen. Any tip on how to solve it? Thanks
Follow the code of the dialog:import QtQuick 2.7 import QtQuick.Dialogs 1.2 import QtQuick.Controls 1.4 import QtQuick.Window 2.2 import QtQuick.Layouts 1.3 Dialog { id: printerSettingsDialog visible: false title: qsTr("General Settings") standardButtons: StandardButton.Save | StandardButton.Cancel TabView { id: tabs anchors.fill: parent Tab { id: bedSettings title: qsTr("Bed:") BedSettings { id: bedTab } } Tab { id: extruderSettings title: qsTr("HotEnd:") ExtruderSettings { id: extruderTab } } } //End TabView onAccepted: {/*TODO: Save on Settings profile*/} onRejected: {/*TODO: Discard changes*/} }
-
@Lays147 The docs says:
... and Dialog will attempt to size itself to fit the content and the buttons.
So it tries to do so but I guess it might fail too.
Also you have not specifiedwidth
andheight
for its childTabView
. Try specifying one so thatDialog
may be resized to that size.
MakingTabView
child ofcontentItem
will solve out the problem but removes the buttons too. You can create those in your code. -
@p3c0 I already tried to set width and height in all ways that I could imagine, and don't work. :(
-
Also, contentItem dont solve the problem, already tried that. I already tried everything that I know, but the dialog continues to trigger in a small size.
Im thinking in abandon that and do a dialog by myself using rectangle and see what happens. -
@Lays147 Make
TabView
child ofDialog
'scontentItem
. Set itsimplicitWidth
andimplicitHeight
. Try this:Dialog { id: printerSettingsDialog visible: true title: qsTr("General Settings") standardButtons: StandardButton.Save | StandardButton.Cancel contentItem: TabView { id: tabs implicitWidth: 800 implicitHeight: 400 Tab { id: bedSettings title: qsTr("Bed:") } Tab { id: extruderSettings title: qsTr("HotEnd:") } } //End TabView }
Then add your own buttons.