Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:17:57+00:00 2026-06-17T21:17:57+00:00

I have a qt quick project where I am trying to emit a signal

  • 0

I have a qt quick project where I am trying to emit a signal from QML and connect to a slot in C++.

QML file

import QtQuick 1.0
//import com.net 1.0

Column {
id: mainCol
x: 20; y: 80
width: 320
//height: 62
opacity: 0

//NetCom{ id: netcom}


Rectangle{
    signal tcpMsg(string address, int port)
    objectName: "topRec"
    id: topRec
    width: 40; height: 40
    color: "blue"
    Text{
        text: "send tcp msg"; font.pointSize: 14
        anchors.verticalCenter: topRec.verticalCenter
        anchors.left: topRec.right
        anchors.rightMargin: 10
    }
    Text{
        id: statusTxt
        //text: cppInterface.qml_text ; font.pointSize: 12
        text: "status: "; font.pointSize: 12
        anchors.horizontalCenter: topRec.horizontalCenter
        anchors.top: topRec.bottom
        anchors.bottomMargin: 10
    }

    MouseArea {
        id: mouseArea
        transformOrigin: Item.Center
        anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
        onClicked: {
            topRec.tcpMsg("127.0.0.1", 8888)
            console.log("clicked")
        }
    }
}


states:[
   State {
        name: "visible";
        PropertyChanges { target:mainCol; opacity: 1;}
    }
]

transitions:[
  Transition {
        from:""; to: "visible"; reversible: true
        NumberAnimation { properties: "opacity"; duration: 500; easing.type: Easing.InOutQuad }
    }
]

}

C++ file

#include <QtGui/QApplication>
#include <QtDeclarative>

#include "qmlcppmediator.h"
#include "qmlapplicationviewer.h"
#include "kernelcom.h"
#include "netcom.h"


Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
//needed to use C++ code in QML
qmlRegisterType<KernelCom>("com.kernel", 1, 0, "KernelCom");
qmlRegisterType<NetCom>("com.net", 1, 0, "NetCom");


QmlApplicationViewer viewer;
viewer.setWindowFlags(Qt::FramelessWindowHint);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/testMenu/main.qml"));

//make signal from Qml file trigger slots in C++
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("qml/testMenu/TCPmenu.qml"));
QObject *object = view.rootObject();
QObject *child = object->findChild<QObject*>("topRec");

qDebug()<<child;
NetCom client;

qDebug()<<QObject::connect(child,SIGNAL(tcpMsg(QString, quint16)), &client, SLOT(start(QString, quint16)));


viewer.showExpanded();

return app->exec();
}

I keep getting the following error message

 QDeclarativeRectangle_QML_3(0x99c5998, name = "topRec") 
 Object::connect: No such signal QDeclarativeRectangle_QML_3::tcpMsg         (QString, quint16)
 Object::connect:  (sender name:   'topRec')
 false 

I have tried using QDecarativeEngine, putting the signal in the main qml item so I dont have use get child and I keep getting the message above.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:17:59+00:00Added an answer on June 17, 2026 at 9:17 pm

    Just figured it out, it wouldnt connect because I was using qunit16 datatype instead of using int in
    I changed the line to this

        connect(child,SIGNAL(tcpMsg(QString, int)), &client, SLOT(start(QString, int))) 
    

    and then it connected.

    Also I didnt need QDeclarativeView I eneded up setting the rootObject from QmlApplicationViewer viewer;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using library openid4java in my project. I have tried to use examples: http://communitygrids.blogspot.com/2009/12/quick-guide-to-using-googles-openid.html
I just have a quick question. Im trying to use Unity with my asp.net
I have this quick question, i have got the username variable from a form
I have an older VB6 project that I'm trying to add unit tests for.
I'm trying to archive my iOS project with Xcode 4.5.2. I do not have
Hey all, quick NHibernate question. In my current project, we have a denormalized table
I have an open source project that deals with mongodb database. I am trying
I'm trying to read up on asp.net mvc, I have never used asp.net before
I'm trying to run a demo project downloaded from GITHUB. And inside it, it
I have a quick and simple question on a small project that I'm starting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.