Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Windows CE QML number oddness
Forum Updated to NodeBB v4.3 + New Features

Windows CE QML number oddness

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    altera_2011
    wrote on last edited by
    #1

    I have the strangest of problems, odd integers are increased by one when they are passed from QML scope into a C++ object (through a Q_PROPERTY) for example 89 becomes 90. 90 stays 90, but 101 becomes 102. As you can imagine this is wreaking havoc on my application. All this ONLY on Windows CE...

    I've been able to recreate this in a simple application:

    MainWindow.h
    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    protected:
    int m_Id;
    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    int id();
    Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged )
    signals:
    void idChanged( int id ) ;
    public slots:
    void setId( int id );

    };

    #endif // MAINWINDOW_H@

    MainWindow.cpp
    @
    #include "mainwindow.h"
    #include <QtDeclarative>
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), m_Id(89)
    {

    QDeclarativeView * view = new QDeclarativeView;
    setCentralWidget(view);
    QDeclarativeEngine * engine = view->engine();
    engine->rootContext()->setContextProperty("myObject", this);
    QUrl url = QUrl::fromLocalFile&#40;"./test.qml"&#41;;
    view->setSource(url&#41;;
    

    }

    MainWindow::~MainWindow()
    {

    }

    void MainWindow::setId(int id)
    {
    if (id != m_Id ) {
    m_Id = id;
    emit idChanged(id);
    }
    }

    int MainWindow::id()
    {
    return m_Id;
    }
    @

    test.qml
    @import QtQuick 1.0

    Text {

    width: 100
    height:100
    text: myObject.id
    MouseArea{

        anchors.fill: parent
        onClicked: {
          myObject.id = 101
        }
    }
    

    }
    @

    Initially this will display the correct value 89, but once we click on the text the value changes to 102, instead of 101. So the bug appears to be inside the code that transfers values to the C++ objects, not the other way around. Any pointers where to start looking in the Qt code for this would be very very appreciated.

    edit: I'm on QT 4.7.3 Windows CE 6

    1 Reply Last reply
    0
    • A Offline
      A Offline
      altera_2011
      wrote on last edited by
      #2

      For future generations this seems to be a compiler bug

      http://bugreports.qt.nokia.com/browse/QTBUG-19792

      Fixed by adding floor calls to round64 function in qglobal.h of the corelib.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved