upload mesh QML - qt

I'am new to Qt and I am trying to upload a mesh (.obj) in my QML file but it does not work. no error and no results.
how can I make it work.
import QtQuick 2.9
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Logic 2.0
import Qt3D.Extras 2.0
import Qt3D.Animation 2.9
import QtQuick.Window 2.2
Viewport{
id:viewroot
normalizedRect: Qt.rect(0, 0, 1, 1)
Entity {
id: sceneRoot
Mesh{
id:carmesh
source:"Bibliothèques\Documents\mercedes.obj"
}
}
}

Related

this.afAuth.signInWithRedirect(new firebase.) the rest is not suggesting

I am new to anguler however in this commandthis.afAuth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
firebase.auth is showing an error can not be fixed
import { Component, OnInit } from '#angular/core';
import {AngularFireAuth} from '#angular/fire/compat/auth';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
import * as firebase from 'firebase/compat';
import "firebase/firestore";
import "firebase/auth";
import "firebase/storage";
#Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent{
constructor(private afAuth:AngularFireAuth) {
}
login(){
this.afAuth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
}
Logout(){
this.afAuth.signOut();
}
}
basicall this code is not working I am missing some thing.

How to import Oh Vue Icons inside Nuxt 3?

Normally in Vue I have main.ts file so I can just import and mount Vue icon into the app, for example:
import { createApp } from 'vue'
import { OhVueIcon, addIcons } from 'oh-vue-icons'
import { MdDragindicator, HiTrash, HiPlus, HiSolidSearch, BiTextLeft, BiTypeH1, BiTypeH2, BiTypeH3, BiHr, BiQuote } from 'oh-vue-icons/icons'
import '#/assets/css/main.css'
import App from './App.vue'
addIcons(MdDragindicator, HiTrash, HiPlus, HiSolidSearch, BiTextLeft, BiTypeH1, BiTypeH2, BiTypeH3, BiHr, BiQuote)
const app = createApp(App)
app.component('v-icon', OhVueIcon)
app.mount('#app')
So how can I do the same thing in Nuxt 3 where I only have nuxt.config.ts

Is it possible to add a Uv cube mapping to a CuboidMesh in QML?

I am developping a 3D cube with 6 different textures and I wanted to know if it's possible to use a cube Uv mapping for a CuboidMesh in QML.
If it's possible, how can I do it ?
I try it but I have the following result :
Here is my code for all the scene including the cube :
import Qt3D.Core 2.12
import Qt3D.Render 2.12
import Qt3D.Extras 2.12
import Qt3D.Input 2.12
import QtQuick 2.12
import QtQuick.Scene3D 2.12
import QtQuick.Window 2.12
import QtQuick 2.15
Entity {
id: root
Entity {
id: cubeEntity
Texture2D {
id: cubeTexture
TextureImage {
source: "qrc:/texture.png"
}
}
CuboidMesh {
id: cubeMesh
xExtent: 1
yExtent: 1
zExtent: 1
}
Transform {
id: cubeTransform
}
ObjectPicker {
id: cubePicker
}
NormalDiffuseMapMaterial{
id: cubeMaterial
diffuse: cubeTexture
normal: cubeTexture
specular: "black"
shininess: 50
}
components: [cubeMesh, cubeTransform, cubeMaterial, cubePicker]
}
}
It works with the Mesh type but I want to use that mapping with a CuboidMesh.
My texture.png is the following image :

Communication between 2 different objects in 2 different QML files

I have one main.qml file and I have other "example.qml" file. When I push a button from "example.qml" file I want to change a text in "main.qml" file. I tried defining the source of the text. I tried send signal. I tried using loader but always came to a dead end.
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Imagine 2.12
import QtQuick.Window 2.0
//main.qml
Window {
visible: true
width: 1080
height: 720
color: "black"
title: qsTr("MY GUI")
Text {
id: deneme
x: 100
y: 400
color: "white"
text: "Trial"
}
}
//example.qml
Item {
id: difflock
Rectangle{
id: diffLockRect
width: 1080
height: 720
color: "red"
signal mySignal
Button{.
onClicked: main.deneme.text = "Finally"
}
}
}
Create a new qml named by Example.qml(first letter should be capital)
Define in main.qml
Example.qml can access the objects in main.qml
main.qml
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Imagine 2.12
import QtQuick.Window 2.0
Window {
visible: true
width: 1080
height: 720
color: "black"
title: qsTr("MY GUI")
Example{id:rfrnc} // You can also reach the other qml objects by using this id
Text {
id: deneme
x: 100
y: 400
color: "white"
text: "Trial"
}
}
Example.qml
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Imagine 2.12
import QtQuick.Window 2.0
Item {
id: difflock
Rectangle{
id: diffLockRect
width: 1080
height: 720
color: "red"
signal mySignal
Button{
onClicked: deneme.text = "Finally"
}
}
}

Declare specific global objects in QML

I am trying to follow this answer, but for more complicated objects:
https://stackoverflow.com/a/25123824/1036082
My files are:
qml.qrc:
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Uconsts.qml</file>
<file>Ucolors.qml</file>
<file>qmldir</file>
</qresource>
</RCC>
main.qml:
import QtQuick 2.9
import QtQuick.Window 2.2
import "."
Window
{
width: 600
height: 400
visible: true
color: Uconsts.colDay.canvas;
}
qmldir:
# qmldir
singleton Uconsts Uconsts.qml
Ucolors.qml:
import QtQuick 2.0
Item
{
property color canvas: "#FFFFFF";
}
Uconsts.qml:
pragma Singleton
import QtQuick 2.9
QtObject
{
property Ucolors colDay:
{
canvas: "#eaedf1";
}
}
When running the program, in runtime I get the following errors from the QML side:
qrc:/main.qml:10: TypeError: Cannot read property 'canvas' of null
qrc:/Uconsts.qml:6:2: Unable to assign QString to Ucolors_QMLTYPE_0*
What am I doing wrong here?
QML does not deduct the type when you use {}, you must create the item explicitly
pragma Singleton
import QtQuick 2.9
QtObject
{
property Ucolors colDay: Ucolors{ canvas: "#eaedf1";}
}

Resources