QT 5.1.1 QML FileDialog - Unkown component (M300) - qt

I'm using QtQuick2 of QT 5.1.1
When I try to include and use the QML Elem FileDialog like described here I just get Unkown component (M300)
If I hover over import QtQuick.Dialogs 1.0 it says "library at: OS-PATH/qml/QtQuick/Dialogs" but in this folder is only a DefaultFileDialog.qml some other stuff but no FileDialog.qml.
So is there any reason why my QT installation doesn't provide this QML type? How can I import it?
Thanks in advance.

have a look here, just ignore the error message. it works for me!
https://qt-project.org/doc/qt-5.1/qtquickdialogs/systemdialogs-filedialogs-qml.html

There is no "FileDialog.qml" at all in QtQuick since the FileDialog is implemented in C++ and exported to QML.
Make sure to
import QtQuick 2.0
import QtQuick.Dialogs 1.0
Last but not least, ignore the warning given by QT Creator. In my case, FileDialog works perfctly but QTCreator does not know about it.

Related

DropShadow QML widget in Qt6

I have a problem:
I need to use DropShadow effect from QGraphicalEffects (which deleted in qt6) in my app.
How I can do it or replace it?
You can still import GraphicalEffects from the Qt5Compat module:
import Qt5Compat.GraphicalEffects
However you first have to install the Qt5Compat module from the Qt installer, which long term might not be what you want in new code as it is going to go away eventually.

How do I import components into QtQuickDesigner?

I am trying to learn Qt version 6, and I'm at a point where my book has me importing QtQuick Controls. The book says to click on the "Imports tab" in the Library pane, and shows a screenshot containing the tab. (Virtually every web source I've been able to find says the same thing, with a similar screenshot.)
Unfortunately, my installation of Qt-Creator, version 4.15.1, installed with Qt 6, does not have an Imports tab on the library pane. This is what my Library pane looks like:
Yes, it appears that the controls have been imported, but I didn't do it through the UI, it happened during an experiment. What got the controls imported was:
I hand-edited the .ui.qml file to add the line
import QtQuick.Controls 2.4
I built the project
This resulted in the QtQuick controls appearing in the Library pane.
Surely this is not the normal way of importing controls, is it?
If I'm understanding correctly, you want Qt Design Studio to import modules for you from the UI.
Simply click here then:
Also, if your project was made with Qt6, there's no need to add the version in the import statement.
I hope I was of any help :)

QtCreator Designer how can I see custom object in QML Types?

I'm pretty new to QtCreator, my issue is that I'm not able to see QML Custom Components.
For example if you import QtQuick.Controls 1.5 you see under QML types:
- Qt Quick - Controls.
So far I have created my personal set of components, here is the folder structure:
the components qmldir is done in that way:
# qmldir
module components
Header 1.0 Header.qml
Footer 1.0 Footer.qml
CentralPage 1.0 CentralPage.qml
GenericButton 1.0 GenericButton.qml
ProgressBarCustom 1.0 ProgressBarCustom.qml
than for example in the LandingPageFrom.ui.qml
import QtQuick 2.6
import QtQuick.Controls 1.5
import QtQuick.Layouts 1.3
import components 1.0 as Components
Components.CentralPage {
pageName: "landingPage"
id: landingPage
width: 800
height: 1056
property alias aButton: aButton
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
And is compiling and showing fine but inside the Designer nothing is showing as aspected, I only see .qml that are in the same directory but not the ones in components directory:
this is what I have done in the .pro and in the main.cpp
QML_IMPORT_PATH += $$PWD/resources/common/ui
QML_DESIGNER_IMPORT_PATH += resources/common/ui
main.cpp
QQmlApplicationEngine engine;
engine.addImportPath("qrc:///ui");
engine.load(QUrl("qrc:///ui/main.qml"));
What is strange is that only the designer is not able to see the components, but the QML code is able, what I'm missing here?
Not sure if you already solved your issue, but try steps 4 and 5 here:
http://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html
That made it work for me, although I had some issues with the metainfo file. You can just use this guys metainfo file as an example(or look at the one the Qt docs referenced in the instructions above): https://forum.qt.io/topic/56207/how-to-load-custom-qml-controls-into-the-qml-designer/2
Just make sure you put the designer folder where your module qmldir is located and the metainfo file goes in there. Probably named components.metainfo judging by the module name, not sure if that matters.

Qml QtQuickControls2, change style properties at runtime

I should set property of Material style at runtime, for example to change theme value (light/dark) when the user click on a defined button.
I have configured Material style with qtquickcontrols2.conf and its properties (theme, accent and primary). I can't import QtQuick.Controls.Materials 2.0 because I don't know, but I'm working on Ubuntu with QtCreator 4.0.2 and the QtQuick.Controls.Materials and QtQuick.Controls.Universal imports are not detected.
My goal is simply change theme of material style from light to dark and viceversa on runtime. How can I integrate this feature? Thanks in advice.
Best Regards
Daniele
I can't import QtQuick.Controls.Materials 2.0 because I don't know, but I'm working on Ubuntu with QtCreator 4.0.2 and the QtQuick.Controls.Materials and QtQuick.Controls.Universal imports are not detected.
You need at least Qt 5.7.0 in order to have the Qt Quick Controls 2.0 import available.
My goal is simply change theme of material style from light to dark and viceversa on runtime.
You switch the theme at runtime like this:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
ApplicationWindow {
id: window
width: 200
height: 200
visible: true
Material.theme: themeSwitch.checked ? Material.Dark : Material.Light
Switch {
id: themeSwitch
text: "Dark"
anchors.centerIn: parent
}
}

QtCreator syntax highlighting when import qml from qrc

When I import qml from qrc (which place in different directory from ) it's compile and work fine.
But when Qt Creator don't recognize imported component and don't hightlight this.
This's code:
import QtQuick 2.0
import "qrc:/qml_libs/ApplicationContainer"
Item
{
id: root_object
width: 300
height: 200
ApplicationContainer {
width : parent.width
height: parent.height
}
}
#Aleus, your way of doing thing is little bit tricky. I can't find any information of such kind importing in official documentation (please, take a look at Importing statements in Qt 5.2, QML. Also, take a look at QML Best Practices: Coding Conventions
First of all, check weather your file ApplicationContainer really has no extension (I mean .qml)
To make QtCreator recognize imported component do next things:
Add your qml file to .pro file in section OTHER_FILES like this:
OTHER_FILES += qml_libs/ApplicationContainer
AND/OR place statement for importing whole directory to your qml file, like:
import "qml_libs" as MyLibs
...
MyLibs.ApplicationContainer { ... }
Hope it helps!

Resources