Hi,
I am new to Qt and therefore this question might be easy to solve (unfortunately not for me).
I have to update a textarea dynamically from C++ code.
Here is what I have so far:

Qt Code:
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.1
  3.  
  4.  
  5. ApplicationWindow {
  6. visible: true
  7. width: 640
  8. height: 480
  9.  
  10. title: qsTr("IMServer")
  11.  
  12. menuBar: MenuBar {
  13. Menu {
  14. title: qsTr("File")
  15. MenuItem {
  16. text: qsTr("Exit")
  17. onTriggered: Qt.quit();
  18. }
  19. }
  20. }
  21.  
  22. TextArea {
  23. id: serverInformation
  24. x: 0
  25. y: 0
  26. width: 247
  27. height: 279
  28. }
  29. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QApplication>
  2. #include <QQmlApplicationEngine>
  3. #include <QQmlContext>
  4. #include <QQmlEngine>
  5. #include <QtQml>
  6.  
  7. #include "imserver.h"
  8.  
  9. int main(int argc, char *argv[]) {
  10. QApplication app(argc, argv);
  11.  
  12. QQmlApplicationEngine engine;
  13. engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
  14.  
  15. IMServer server(2000);
  16.  
  17. qmlRegisterUncreatableType<IMServer>("App", 1, 0, "IMServer", "");
  18. engine.rootContext()->setContextProperty("imserver", &server);
  19.  
  20. server.startServer();
  21.  
  22. return app.exec();
  23. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef IMSERVER_H
  2. #define IMSERVER_H
  3.  
  4. #include <QTcpServer>
  5. #include <QTcpSocket>
  6. #include <QAbstractSocket>
  7. #include <QThreadPool>
  8.  
  9. class IMServer : public QTcpServer {
  10.  
  11. Q_OBJECT
  12. Q_PROPERTY(QString text WRITE setText NOTIFY textChanged)
  13.  
  14. public:
  15. explicit IMServer(int port, QObject *parent = 0);
  16. void startServer();
  17. void setText(const QString &txt);
  18.  
  19. signals:
  20. void textChanged();
  21.  
  22. public slots:
  23.  
  24. protected:
  25. void incomingConnection(qintptr fd);
  26.  
  27. private:
  28. int port;
  29. QThreadPool *pool;
  30. QString m_text;
  31. };
  32.  
  33.  
  34. #endif // IMSERVER_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "imserver.h"
  2. #include "clienthandler.h"
  3.  
  4. IMServer::IMServer(int port, QObject *parent) : QTcpServer(parent) {
  5. this->pool = new QThreadPool(this);
  6. this->pool->setMaxThreadCount(100);
  7. this->port = port;
  8. }
  9.  
  10. void IMServer::startServer() {
  11.  
  12. setText("TEST");
  13.  
  14. if (!this->listen(QHostAddress::Any, this->port)) {
  15. qDebug() << "Server could not be started";
  16. } else {
  17. qDebug() << "Server started, listening...";
  18. }
  19. }
  20.  
  21. void IMServer::setText(const QString &txt) {
  22. m_text = txt;
  23. emit textChanged();
  24. }
  25.  
  26.  
  27. void IMServer::incomingConnection(qintptr fd) {
  28. ClientHandler *client = new ClientHandler();
  29. client->setAutoDelete(true);
  30. client->fd = fd;
  31. this->pool->start(client);
  32. }
To copy to clipboard, switch view to plain text mode 

But the textarea is not updating, can anyone pls tell me what I missed?