I work in Qt5.9.3, writing a qml program in linux platform without x window.
Following is my code:
import Qt3D.Core 2.13
Entity {
id: sceneRoot
...
Transform{
id: torusTransform
scale3D: Qt.vector3d(1.5, 1, 0.5)
rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
...
}
However ,there is a underline in Transform in Qt creater.
The underline in Transform means something error happened.I am sure that Qt53DCore lib has added in .pro file.
So my question is:
How can I know the version of Qt3D.core ?
And how to ensure the specified qml type in the lib?
I don't know if there are a easy way but you can check the old Qt documentation to have an idea of which version you need.
In your example you should use import Qt3D.Core 2.0.
I search the "Entity" keyword in Qt5.9.3 folder, in .../Qt5.9.3/qml/Qt3D/Core path, there is a file named plugins.qmltypes.
I open it and found the code:
Component {
name: "Qt3DCore::Quick::Quick3DEntity"
defaultProperty: "data"
prototype: "Qt3DCore::QEntity"
exports: ["Qt3D.Core/Entity 2.0"]
exportMetaObjectRevisions: [0]
Property { name: "components"; type: "Qt3DCore::QComponent"; isList: true; isReadonly: true }
}
"exports: ["Qt3D.Core/Entity 2.0"]" tell me the version and qml type name.
Related
Goal: To access neighboring folder/classes within the source folder.
Scenario: I have two classes:
RicPackage (default) and
Apple
The 'RicPackage' was auto-generated upon the creation of the Swift Package 'RicPackage'. I want to expand and try to access other folders w/classes autonomously.
Here's the manifest that I'm working on:
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RicPackage",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "RicPackage",
targets: ["RicPackage"]),
.library(
name: "Apple",
targets: ["Apple"]),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "RicPackage",
dependencies: []),
.target(
name: "Apple",
dependencies: []),
.testTarget(
name: "RicPackageTests",
dependencies: ["RicPackage"]),
]
)
I want to be able to access 'Apple' and other such folders independently from the host program.
Here's the Apple source code:
import Foundation
class Apple {
public private(set) var text = "Hello from Apple!"
public init() {
}
public func eat() -> String {
print("Inside Eat Apple")
return "Hello from Eat Apple."
}
}
Here's the test.
Once I get this to work, I'll try to access it from the host application.
I believe that classes & functions must be 'pubic' to be seen.
Questions:
What am I doing wrong with the package manifest file?
Must a target class file have the same name as its folder container?
... for example: 'Apple/Apple.swift'.
So in RicPackageTest, you can't find Apple. Is there an import missing? Not necessarily, you won't find it either.
It's because in the way that RicPackageTest is constructed it has no knowledge of the Apple package.
You wrote:
.testTarget(
name: "RicPackageTests",
dependencies: ["RicPackage"]),
That's what's missing, you aren't saying that RicPackageTests should "depend" (ie "knows of") Apple package.
So you should do:
.testTarget(
name: "RicPackageTests",
dependencies: ["RicPackage", "Apple"]),
Thanks to Larme for correctly answering my novice question.
Here's the solution:
Need dependency:
Need reference in test:
I got the following error message when upgraded to Qt 5.15:
QML Connections: Implicitly defined onFoo properties in Connections are deprecated.
Use this syntax instead: function onFoo(<arguments>) { ... }
The corresponding QML code is pasted below
Connections {
target: AppProxy
onLogsReady: function(logs) {
textLogs.text = logs
}
}
where the onLogsReady is a signal defined in the AppProxy class:
class AppProxy : public QObject {
Q_OBJECT
Q_DISABLE_COPY(AppProxy)
public:
AppProxy(QObject* parent = 0);
~AppProxy();
signals:
void logsReady(QString logs);
// ...
};
I wonder how to suppress this warning.
in Qml 5.15 there is a new syntax for connections. In your case it would look like this:
Connections {
target: AppProxy
function onLogsReady(logs) {
textLogs.text = logs
}
}
You can read more about it here: https://doc.qt.io/qt-5/qml-qtqml-connections.html
In addtion to #luffy and #Lidekys solution in my case adding this line to pro file of the project is solved issue.
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#luffy answer is correct, but not completely. If you'll just make these changes, at least for me, it didn't fix the issue. What fixed it was adding "import QtQml 2.15" (like stated in https://doc.qt.io/qt-5/qml-qtqml-connections.html) in the qml files that were affected by these changes.
Not sure if this helps, just wanted to add in to the issue.
I installed the moment.js library and was about to play around with it a little bit, when i got this error. I've tried many different things, but nothing has worked. Any ideas?
I have a folder that i've installed moment.js into (npm install moment) and i'm running my program (node isDate.js).
import {moment} from 'moment';
function isDate(string) {
{
moment(string).format(["MM-DD-YYYY", "YYYY-MM-DD"]);
}
} exports.isDate = isDate;
ReferenceError: moment is not defined
As per Aleks comment
const moment= require('moment')
worked for me.
Change this
import {moment} from 'moment';
to this
const moment= require('moment')
You can use this to import moment.
import * as moment from 'moment';
In case the other solution proposals don't work out, checking for hoisting behavior might help.
Here's what helped in my particular case.
Using your example code, it would be changing the function declaration:
import * as moment from 'moment';
function isDate(string) {
return moment(string).format(["MM-DD-YYYY", "YYYY-MM-DD"]);
}
to a function expression:
import * as moment from 'moment';
const isDate = (string) => {
return moment(string).format(["MM-DD-YYYY", "YYYY-MM-DD"]);
}
This resolved the reference error 'moment is not defined' in our React code base, where the function which uses 'moment' was imported in a component file.
See also 'Function Hoisting': Functions - JavaScript | MDN
I am having trouble with scss module imports when I am running flow check. I have tried out various approaches including
.flowconfig
[options]
module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/flow-typed/stub/css-module.js'
and I have
// #flow
type CSSModule = { [key: string]: string }
const emptyCSSModule: CSSModule = {}
export default emptyCSSModule
in the css-module.js. Do you know why it's happening?
I believe I had a similar issue when trying to use .styl files for stylus.
You might be able to solve this issue by doing the following which had worked for me:
Remove the css-module.js file.
Remove that module.name_mapper.extension line that you have in your .flowconfig
Add the following to the [options] in your .flowconfig:
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.scss
How do I correctly import my collection definition?
I get this error message when as a result of trying to import
I externalized my collection definition FROM the main myMeteorApp.js file:
(My directory structure looked like this:)
/myMeteorApp
/myMeteorApp.js
...TO the tasks.js file:
(My directory structure currently looks like this:)
/myMeteorApp
--/imports/api/tasks.js
The contents of tasks.js look like this:
import { Mongo } from "meteor/mongo";
const Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});
const buyList = new Mongo.Collection("BuyList");
const WhoAreWe = new Mongo.Collection("whoDb");
const merchantReviews = new Mongo.Collection("MerchantReviews");
const Messages = new Meteor.Collection("messages", {transform: function (doc) { doc.buyListObj = buyList.find({sessionIDz: {$in: [doc.buyList]}}); return doc; }});
export { Images };
export { buyList };
export { WhoAreWe };
export { merchantReviews };
export { Messages };
I have packages babel-preset-es2015 and ecmascript installed, but these haven't helped.
Looking forward to your help...
Everything is the chat session we had indicates that your original app used Meteor 1.2, which did not support ES2015 modules. In addition, you did not import them correctly.
Here is a short checklist for import-related issues:
Make sure that your project is actually using Meteor v1.3+ (run meteor --version). Earlier versions did not support the modules feature.
Make sure that you have the ecmascript package installed (run meteor list or cat .meteor/packages | grep ecmascript from your project's root directory. If not, meteor add ecmascript. This is the package used for compiling ES2015.
Make sure that you are using it correctly. There are 2 types of exports:
default - import foo from 'imports/bar' goes with export default bar.
named - import { foo } from 'imports/bar' goes with export const foo = ..., etc.