lmport/Export .dwg file to Scene3d in qt3d - qml

I have a simple program that has Scene3d in qml like this code :
Scene3D
{
id : scene3d
anchors.fill: parent
focus: true
aspects: ["render", "logic", "input"]
hoverEnabled: true
cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
antialiasing: true
}
I want to load a .dwg AutoCAD file in this Scene3D . I know that for doing this I should use a library like Assimp but the problem is that Assimp doesn't support this format of files so I find libdxfrw but I don't know how should I use it in my project and how to use it in qml Scene3d.
I know that SceneLoader can import .obj files , is there any way to convert .dwg files to .obj ?

Related

QML: contentItem does not show any Image

I am using QML to design a small user interface.
The problem I have is that I need to select an image if a certain conditions happens or not, and nothing happens because I may have something wrong in the contentItem below, I set a simple a if loop that replicates exactly the problem I have:
main.qml
// operations ....
Row {
anchors.fill: parent
anchors.leftMargin: 20
anchors.topMargin: 20
Button {
id: button
width: 90
height: 270
contentItem: Item {
Image {
source: root.selected === 0 ?
source: "qrc:/images/btn-Modes-on.png" :
source: "qrc:/images/btn-modes-normal.png"
}
}
// operations ....
}
I believe the problem is where I set the if loop for the images. I can confirm that the path of the images is correct and double checked.
I also used according to the documentation the proper notation of the images, and the property I am using is source: "path to your image".
However after checking that I still also have no return.
Thanks for pointing in the right direction to solve this problem.
There's a typo in your code. The Image source should look like this:
source: root.selected === 0 ?
"qrc:/images/btn-Modes-on.png" :
"qrc:/images/btn-modes-normal.png"

QML error "Unknown component. (M300)" but the code works

I want to use a custom font in a QML application, and to not have to specify it in every text field, I use a component as suggested in this answer.
I have a DefaultText.qml under a styles prefix in my qml.qrc, which resides in the folder styles.
import QtQuick 2.0
Text {
color: "black"
font.family: myCustomFont.name
font.bold: false
font.italic: false
font.pixelSize: 14
}
I use it, among other places, in a qml named PanelRight.qml, under the prefix Panels in the folder widgets. It's all under the same qml.qrc.
import "qrc:/styles/styles"
Item
{
// ...
DefaultText { text: "xyz" }
}
Interestingly, DefaultText is underlined as an error, with the message "Unknown component. (M300)". However, I can successfully compile and run my application, and the custom font is displayed correctly. However, it's annoying that I have a long list of errors (I intend to use it in a lot of places) and that autocomplete doesn't work.
I searched the Qt forums, this problem was mentioned there in case of custom plugins, which I don't use.
Add relative path of DefaultText.qml in PanelRight.qml file as
import "../styles"
import QtQuick.Controls.Material

Passing QML events to C++ or VTK

How do I pass QML events to C++ code? I want to manage these events by passing them to a VTK interactor.
In QML code:
// some shape
Rectangle {
signal signalEvent333
onYourEvent: {
signalEvent333();
}
And in C++ code:
auto* qqView = new QQuickView(); // don't forget to delete sometimes
qqView->setSource(QUrl(QStringLiteral("qrc:///res/qml/myQmlForm.qml"))); // if that qml form in the app resource
QQuickItem* root = qqView->rootObject();
connect((QObject*)root, SIGNAL(signalEvent333()), this, SLOT(onSignalEvent333()));
We assume we have onSignalEvent333 slot for 'this' object.
P.S. And this question should be marked Qt as well. And I don't know what VTK is.

QtDesktop components crash on mouse move

I'm trying to use Qt 5 with QtDesktop components in Windows 8 x64 and when I build and run app and move mouse, app is crashing with this message in log:
QPainter::begin: A paint device can only be painted by one painter at a time.
It happens only if mouse move in any component, if i have qml like this:
import QtQuick 2.0
import QtDesktop 1.0
Rectangle {
width: 360
height: 360
Button {
text: "testButton"
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
everything will be ok before I move cursor into button. Somebody have any ideas what is it and how i can fix this? It isn't the error in my code because building tests/tableviewmodels and examples/ApplicationTemplate gives the same result
If it important, I use Visual Studio 2010 Express + Qt Creator 2.6.1
PS not sure, but I think I build and run QtDesktopComponents on this PC about two weeks ago and there wasn't this error, and it was windows update after that
UPD
It was Qt Quick Components bug, fixed in https://bugreports.qt-project.org/browse/QTCOMPONENTS-1287

what is the format for saving a qml QVariantList<QVariant> in qml file so it can be bindable in qml when loading the file?

i am doing an application and i need to save the QVariantList list in a qml file so i can load it in qml every time i start the application
to make it more clear i read qpoints from qml and store them in a qvariantlist in c++ so the next step is to save it in text file i use the format(that's how i write it to file.qml)
import ARHandbook 1.0;
x:["1 2" , "1 3"]
but it doesnt load in qml so what is the right format to store it with ?
it gives this error unable to assin qvariantlist to void
For QtQuick 1.x, you should use property variant type, from QtQuick 2.0, you can just use property var to store array types.
See
http://doc-snapshot.qt-project.org/5.0/qml-var.html and http://qt-project.org/doc/qt-4.8/qml-variant.html for details.