I called Clickcheck() from QML with
Settings.clickcheck();
Settings.clickcheck();
To copy to clipboard, switch view to plain text mode
and when I pressed mouse area this show me old variable.
There's another code with same "error":
#ifndef KEPPOXD_H
#define KEPPOXD_H
#include <QObject>
#include <QDebug>
{
Q_OBJECT
public:
explicit keppoxd
(QObject *parent
= nullptr
);
signals:
public slots:
void test();
};
#endif // KEPPOXD_H
#ifndef KEPPOXD_H
#define KEPPOXD_H
#include <QObject>
#include <QDebug>
class keppoxd : public QObject
{
Q_OBJECT
public:
explicit keppoxd(QObject *parent = nullptr);
QString name = "old";
signals:
void textChanged(QString);
public slots:
void setWindowName(QString value);
void test();
};
#endif // KEPPOXD_H
To copy to clipboard, switch view to plain text mode
#ifndef SIEMA_H
#define SIEMA_H
#include <QObject>
#include <QDebug>
#include <keppoxd.h>
{
Q_OBJECT
public:
explicit siema
(QObject *parent
= nullptr
);
keppoxd keppo;
signals:
public slots:
};
#endif // SIEMA_H
#ifndef SIEMA_H
#define SIEMA_H
#include <QObject>
#include <QDebug>
#include <keppoxd.h>
class siema : public QObject
{
Q_OBJECT
public:
explicit siema(QObject *parent = nullptr);
keppoxd keppo;
signals:
void textChanged(QString);
public slots:
void setWindowName(QString value);
};
#endif // SIEMA_H
To copy to clipboard, switch view to plain text mode
#include "keppoxd.h"
{
}
void keppoxd
::setWindowName(QString value
) {
connect(this,
SIGNAL (textChanged
(QString)),
this,
SLOT(setWindowName
(QString)));
name = value;
qDebug() << name;
}
void keppoxd::test()
{
qDebug() << "keppo test " << name;
}
#include "keppoxd.h"
keppoxd::keppoxd(QObject *parent) : QObject(parent)
{
}
void keppoxd::setWindowName(QString value)
{
connect(this, SIGNAL (textChanged(QString)), this, SLOT(setWindowName(QString)));
name = value;
qDebug() << name;
}
void keppoxd::test()
{
qDebug() << "keppo test " << name;
}
To copy to clipboard, switch view to plain text mode
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSettings>
#include <QDir>
#include <QDebug>
#include <keppoxd.h>
#include <siema.h>
#include <QQmlContext>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
//QSettings* settings;
/*if(QFileInfo::exists(QDir::currentPath() + "/my_config_file.ini")){
qDebug() << "istnieje";
}
else{
qDebug() << "nie istnieje";
settings = new QSettings(QDir::currentPath() + "/my_config_file.ini", QSettings::IniFormat);
settings->setValue("test", "value");
settings->setValue("Button", 1);
settings->sync();
} */
siema siema;
keppoxd keppo;
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("Siema", &siema);
ctx->setContextProperty("Keppo", &keppo);
return app.exec();
}
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSettings>
#include <QDir>
#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);
//QSettings* settings;
/*if(QFileInfo::exists(QDir::currentPath() + "/my_config_file.ini")){
qDebug() << "istnieje";
}
else{
qDebug() << "nie istnieje";
settings = new QSettings(QDir::currentPath() + "/my_config_file.ini", QSettings::IniFormat);
settings->setValue("test", "value");
settings->setValue("Button", 1);
settings->sync();
} */
siema siema;
keppoxd keppo;
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("Siema", &siema);
ctx->setContextProperty("Keppo", &keppo);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
#include "siema.h"
{
}
void siema
::setWindowName(QString value
) {
connect(this,
SIGNAL (textChanged
(QString)),
this,
SLOT(setWindowName
(QString)));
keppo.name = value;
qDebug() << keppo.name;
}
#include "siema.h"
siema::siema(QObject *parent) : QObject(parent)
{
}
void siema::setWindowName(QString value)
{
connect(this, SIGNAL (textChanged(QString)), this, SLOT(setWindowName(QString)));
keppo.name = value;
qDebug() << keppo.name;
}
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
x: 48
y: 58
width: 80
height: 20
text: qsTr("Text Input")
font.pixelSize: 12
onTextEdited:{
Siema.setWindowName(textInput.text);
Keppo.test();
}
}
Rectangle {
id: rectangle
x: 276
y: 41
width: 200
height: 200
color: "#e30a0a"
MouseArea {
id: mouseArea
x: 0
y: 0
width: 200
height: 200
onClicked:{
Siema.setWindowName(textInput.text);
Keppo.test();
}
}
}
}
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextInput {
id: textInput
x: 48
y: 58
width: 80
height: 20
text: qsTr("Text Input")
font.pixelSize: 12
onTextEdited:{
Siema.setWindowName(textInput.text);
Keppo.test();
}
}
Rectangle {
id: rectangle
x: 276
y: 41
width: 200
height: 200
color: "#e30a0a"
MouseArea {
id: mouseArea
x: 0
y: 0
width: 200
height: 200
onClicked:{
Siema.setWindowName(textInput.text);
Keppo.test();
}
}
}
}
To copy to clipboard, switch view to plain text mode
Log:
istnieje
"Text Input"
keppo test "old"
"Text Input"
keppo test "old"
"Text Ixnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
istnieje
"Text Input"
keppo test "old"
"Text Input"
keppo test "old"
"Text Ixnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
"Text Ixdnput"
keppo test "old"
To copy to clipboard, switch view to plain text mode
Bookmarks