[Interest] Syncing settings between QML and C++

2020-05-13 Thread Marc Van Daele
Hello,

I try to read settings in C++ that are written from within QML.
But apparently, I need some delay between writing the value in QML and
reading the new value in C++ (even when calling settings.sync() in both QML
and C++).
Apparently, I have to wait about 1000ms (500ms sometimes works, sometimes
doesn't)

The following code illustrates the problem.
My QML code looks like this

import QtQuick 2.12

import QtQuick.Window 2.12

import Qt.labs.settings 1.0


Window {

id: root

visible: true

width: 640

height: 480

title: qsTr("Hello World")


property int ctr: 0


Settings {

id: settingsId

property alias ctr: root.ctr

onCtrChanged: {

console.info("QML: before C++ call ctr = "+root.ctr + "//" + ctr)

settingsId.sync();

readSettings.printSettings("try ")

Qt.callLater(tryAgain)

tryAnotherTime.start()

console.info("QML: after C++ call ctr = "+root.ctr)

}


function tryAgain() {

settingsId.sync();

readSettings.printSettings("try again ")

}

}


Timer {

id: tryAnotherTime

interval: 1000

onTriggered: readSettings.printSettings("try in timer ")

}


MouseArea {

anchors.fill: parent

onClicked: root.ctr++

}

}


The relevant C++ printSettings() function is

void ReadSettings::printSettings(QString prefix)

{

QSettings settings;

settings.sync();

int ctr = settings.value("ctr", "-1").toInt();

qInfo() << "ReadSettings::printSettings "<< prefix << " read ctr=" << ctr;

}

The ReadSettings object is registered as a context property in main.pp

When I run this code, I get the following log lines

qml: QML: before C++ call ctr = 8//8
ReadSettings::printSettings  "try "  read ctr= 7
qml: QML: after C++ call ctr = 8
ReadSettings::printSettings  "try again "  read ctr= 7
ReadSettings::printSettings  "try in timer "  read ctr= 8

This shows that the first two calls to printSettings still print the old value.

The call after 1000ms prints the correct value


Is this a bug?  Do you see work-arounds I can try?


Kind Regards,


Marc
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt 5.15 for Linux/X11 : "-qt-xcb" no longer supported?

2020-05-13 Thread Kai Köhne
And indeed the linux documentation wasn't updated yet :/

https://codereview.qt-project.org/c/qt/qtdoc/+/300239

Kai

Von: Interest  Im Auftrag von Shawn Rutledge
Gesendet: Mittwoch, 13. Mai 2020 17:14
An: interestqt-project.org 
Betreff: Re: [Interest] Qt 5.15 for Linux/X11 : "-qt-xcb" no longer supported?




On 2020 May 13, at 16:57, Viet-Tam Luu via Interest 
mailto:interest@qt-project.org>> wrote:

Hi folks,

we've long used the -qt-xcb configure option to build Qt XCB support without 
supplying the boatload of pesky dependencies, but contrary to what the Qt 5.15 
"Requirements" page 
(https://doc-snapshots.qt.io/qt5-5.15/linux-requirements.html) says, it no 
longer appears to be supported, now instead being a boolean argument according 
to the configure error message I get when I try to specify it, and confirmed by 
looking in qtbase/src/gui/configure.json.

Were the Qt-supplied XCB libraries removed from the Qt sources (and the 
documentation is just out of date), or is the option still supported except for 
a bug in the configure scripts?

They were removed in this patch: 
https://codereview.qt-project.org/c/qt/qtbase/+/253905


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt 5.15 for Linux/X11 : "-qt-xcb" no longer supported?

2020-05-13 Thread Shawn Rutledge


> On 2020 May 13, at 16:57, Viet-Tam Luu via Interest  
> wrote:
> 
> Hi folks,
> 
> we've long used the -qt-xcb configure option to build Qt XCB support without 
> supplying the boatload of pesky dependencies, but contrary to what the Qt 
> 5.15 "Requirements" page 
> (https://doc-snapshots.qt.io/qt5-5.15/linux-requirements.html 
> ) says, it no 
> longer appears to be supported, now instead being a boolean argument 
> according to the configure error message I get when I try to specify it, and 
> confirmed by looking in qtbase/src/gui/configure.json.
> 
> Were the Qt-supplied XCB libraries removed from the Qt sources (and the 
> documentation is just out of date), or is the option still supported except 
> for a bug in the configure scripts?

They were removed in this patch: 
https://codereview.qt-project.org/c/qt/qtbase/+/253905


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Qt 5.15 for Linux/X11 : "-qt-xcb" no longer supported?

2020-05-13 Thread Viet-Tam Luu via Interest
Hi folks,

we've long used the -qt-xcb configure option to build Qt XCB support
without supplying the boatload of pesky dependencies, but contrary to what
the Qt 5.15 "Requirements" page (
https://doc-snapshots.qt.io/qt5-5.15/linux-requirements.html) says, it no
longer appears to be supported, now instead being a boolean argument
according to the configure error message I get when I try to specify it,
and confirmed by looking in qtbase/src/gui/configure.json.

Were the Qt-supplied XCB libraries removed from the Qt sources (and the
documentation is just out of date), or is the option still supported except
for a bug in the configure scripts?

Regards,

- Tam
--
Viet-Tam Luu
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest