Hello, I have an program. It's probably work's normally but in "Application Output" I got some Reference Errors:
qrc:/main.qml:17: ReferenceError: Keppoqml is not defined
qrc:/main.qml:17: ReferenceError: Keppoqml is not defined
qrc:/main.qml:17: ReferenceError: Keppoqml is not defined
qrc:/main.qml:17: ReferenceError: Keppoqml is not defined
To copy to clipboard, switch view to plain text mode
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextInput {
id: textInput
objectName:"inputText"
x: 48
y: 58
width: 80
height: 20
text: Keppoqml.message // Here's the error.
font.pixelSize: 12
onTextEdited:{
Keppoqml.setWindowName(textInput.text);
}
}
Rectangle {
id: rectangle
x: 276
y: 41
width: 112
height: 56
color: "#e30a0a"
MouseArea {
id: mouseArea
x: 0
y: 0
width: 112
height: 56
onClicked:{
Siemaqml.check();
}
}
}
Rectangle {
id: rectangle1
x: 276
y: 180
width: 112
height: 62
color: "#29ff46"
MouseArea {
id: mouseArea1
x: 0
y: 0
width: 112
height: 62
onClicked:{
Siemaqml.load();
}
}
}
Rectangle {
id: rectangle2
x: 36
y: 227
width: 101
height: 106
color: "#000000"
MouseArea {
id: mouseArea2
x: 0
y: 0
width: 101
height: 106
onClicked:{
Keppoqml.checkload();
}
}
}
Rectangle {
id: rectangle5
x: 276
y: 324
width: 112
height: 62
color: "#29ff46"
MouseArea {
id: mouseArea5
x: 0
y: 0
width: 112
height: 62
onClicked:{
Keppoqml.message;
}
}
}
}
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextInput {
id: textInput
objectName:"inputText"
x: 48
y: 58
width: 80
height: 20
text: Keppoqml.message // Here's the error.
font.pixelSize: 12
onTextEdited:{
Keppoqml.setWindowName(textInput.text);
}
}
Rectangle {
id: rectangle
x: 276
y: 41
width: 112
height: 56
color: "#e30a0a"
MouseArea {
id: mouseArea
x: 0
y: 0
width: 112
height: 56
onClicked:{
Siemaqml.check();
}
}
}
Rectangle {
id: rectangle1
x: 276
y: 180
width: 112
height: 62
color: "#29ff46"
MouseArea {
id: mouseArea1
x: 0
y: 0
width: 112
height: 62
onClicked:{
Siemaqml.load();
}
}
}
Rectangle {
id: rectangle2
x: 36
y: 227
width: 101
height: 106
color: "#000000"
MouseArea {
id: mouseArea2
x: 0
y: 0
width: 101
height: 106
onClicked:{
Keppoqml.checkload();
}
}
}
Rectangle {
id: rectangle5
x: 276
y: 324
width: 112
height: 62
color: "#29ff46"
MouseArea {
id: mouseArea5
x: 0
y: 0
width: 112
height: 62
onClicked:{
Keppoqml.message;
}
}
}
}
To copy to clipboard, switch view to plain text mode
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <keppoxd.h>
#include <siema.h>
#include <QQmlContext>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
siema siema;
keppoxd keppo;
keppo.siema = &siema;
QQmlApplicationEngine engine;
const QUrl url
(QStringLiteral
("qrc:/main.qml"));
QObject::connect(&engine,
&QQmlApplicationEngine
::objectCreated,
if (!obj && url == objUrl)
}, Qt::QueuedConnection);
engine.load(url);
QQmlContext *ctx = engine.rootContext();
ctx->setContextProperty("Siemaqml", &siema);
ctx->setContextProperty("Keppoqml", &keppo);
return app.exec();
}
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <keppoxd.h>
#include <siema.h>
#include <QQmlContext>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
siema siema;
keppoxd keppo;
keppo.siema = &siema;
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
QQmlContext *ctx = engine.rootContext();
ctx->setContextProperty("Siemaqml", &siema);
ctx->setContextProperty("Keppoqml", &keppo);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
#ifndef KEPPOXD_H
#define KEPPOXD_H
#include <QObject>
#include <QDebug>
#include <QSettings>
#include <QDir>
#include <siema.h>
{
Q_OBJECT
public:
explicit keppoxd
(QObject *parent
= nullptr
);
siema *siema;
Q_PROPERTY(QString message READ message WRITE setWindowName NOTIFY textChanged
)
signals:
void textChanged();
public slots:
qDebug() << siema->name;
return siema->name;
}
void checkload();
};
#endif // KEPPOXD_H
#ifndef KEPPOXD_H
#define KEPPOXD_H
#include <QObject>
#include <QDebug>
#include <QSettings>
#include <QDir>
#include <siema.h>
class keppoxd : public QObject
{
Q_OBJECT
public:
explicit keppoxd(QObject *parent = nullptr);
siema *siema;
Q_PROPERTY(QString message READ message WRITE setWindowName NOTIFY textChanged)
signals:
void textChanged();
public slots:
QString message(){
qDebug() << siema->name;
return siema->name;
}
void setWindowName(QString value);
void checkload();
};
#endif // KEPPOXD_H
To copy to clipboard, switch view to plain text mode
#include "keppoxd.h"
{
connect(this, SIGNAL (textChanged()), this, SLOT(message()));
}
void keppoxd
::setWindowName(QString value
) {
siema->name = value;
qDebug() << "siema.name value from keppo class " << siema->name;
}
void keppoxd::checkload()
{
qDebug() << "keppoload " << siema->name;
emit textChanged();
}
#include "keppoxd.h"
keppoxd::keppoxd(QObject *parent) : QObject(parent)
{
connect(this, SIGNAL (textChanged()), this, SLOT(message()));
}
void keppoxd::setWindowName(QString value)
{
siema->name = value;
qDebug() << "siema.name value from keppo class " << siema->name;
}
void keppoxd::checkload()
{
qDebug() << "keppoload " << siema->name;
emit textChanged();
}
To copy to clipboard, switch view to plain text mode
#ifndef SIEMA_H
#define SIEMA_H
#include <QObject>
#include <QDebug>
#include <QSettings>
#include <QDir>
#include <QQuickView>
{
Q_OBJECT
public:
explicit siema
(QObject *parent
= nullptr
);
signals:
public slots:
void check();
void load();
};
#endif // SIEMA_H
#ifndef SIEMA_H
#define SIEMA_H
#include <QObject>
#include <QDebug>
#include <QSettings>
#include <QDir>
#include <QQuickView>
class siema : public QObject
{
Q_OBJECT
public:
explicit siema(QObject *parent = nullptr);
QString name = "old";
signals:
public slots:
void check();
void load();
};
#endif // SIEMA_H
To copy to clipboard, switch view to plain text mode
#include "siema.h"
{
}
void siema::check()
{
qDebug() << "siema value " << name;
settings->setValue("textfield", name);
settings->sync();
}
void siema::load(){
name = settings->value("textfield").toString();
}
#include "siema.h"
siema::siema(QObject *parent) : QObject(parent)
{
}
void siema::check()
{
qDebug() << "siema value " << name;
QSettings* settings;
settings = new QSettings(QDir::currentPath() + "/config.ini", QSettings::IniFormat);
settings->setValue("textfield", name);
settings->sync();
}
void siema::load(){
QSettings* settings;
settings = new QSettings(QDir::currentPath() + "/config.ini", QSettings::IniFormat);
name = settings->value("textfield").toString();
}
To copy to clipboard, switch view to plain text mode
Bookmarks