[SOLVED] Read checkbox checked state?
-
wrote on 18 Feb 2014, 15:47 last edited by
JKSH - thanks, I had already tried that but it didn't work.. :-(
HOWEVER, I did the following, which I hadn't before: I went to File->New File or Project->C++->C++ Class to create a new class, versus just making a class in my header file. Once completed, I transferred my class to the new file and lo and behold, it compiled. I tried to do a test run, and it gave me a connection error, which I'm still currently working on...
QObject::connect: Cannot connect (null)::buttonClicked_enable() to TLA_Funcs::sys_enable()
-
wrote on 18 Feb 2014, 18:03 last edited by
Just to be clear, my code is now this:
header file:
@class TLA_Funcs : public QObject
{
Q_OBJECT
public:
explicit TLA_Funcs(QObject *parent = 0);
signals:public slots:
Q_INVOKABLE void sys_enable(){return;}. . .
};@.cpp file:
@#include " ... "
TLA_Funcs::TLA_Funcs(QObject *parent) :
QObject(parent)
{
}int main (int argc, char*argv[]) {
QGuiApplication app(argc, argv); QQuickView *view = new QQuickView(QUrl("main.qml")); view->show(); QQuickItem *item = view->rootObject(); TLA_Funcs *funcs = new TLA_Funcs(); // connect button signals to their slots: QObject::connect(item, SIGNAL(buttonClicked_enable()), funcs, SLOT(sys_enable()));
return 0;
}@QML:
@Rectangle {
id: main
width: 800
height: 600
color: "#abcfe9"
border.width: 4
border.color: "#000000"signal buttonClicked_enable Button { id: autoupdate x: 628 y: 55 text: "AutoUpdate" onClicked:buttonClicked_enable()
}@
It builds fine, but when I run it, I get the error:
"QObject::connect: Cannot connect (null)::buttonClicked_enable() to TLA_Funcs::sys_enable()"
I tried using @onClicked:main.buttonClicked_enable()@
to connect... I also tried using your method from the previous post you suggested:@onClicked:{
buttonClicked_enable()
TLA_Funcs.sys_enable()
}@but it still gives me the same error. Did I miss something? Do I need to list my signals under "signals" in the class? if so, would they be posted the same way as in the QML code?
@
signals:
buttonClicked_enable()@Please advise, this is tormenting me because I'm getting the feeling that it is one of those things that's staring me in the face... only this time it's laughing at me...
-
wrote on 19 Feb 2014, 18:55 last edited by
Cancel that last request. Problem solved. There was an issue with the .pro file. I have since created a new project, copied my code into it, and it works correctly!!! Thanks all, especially JKSH, for all the help with affording me an opportunity to learn!!!
21/23