Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Read checkbox checked state?
Forum Update on Monday, May 27th 2025

[SOLVED] Read checkbox checked state?

Scheduled Pinned Locked Moved General and Desktop
23 Posts 3 Posters 13.8k Views
  • 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.
  • J Offline
    J Offline
    jediengineer
    wrote on 18 Feb 2014, 15:47 last edited by
    #21

    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()

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jediengineer
      wrote on 18 Feb 2014, 18:03 last edited by
      #22

      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...

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jediengineer
        wrote on 19 Feb 2014, 18:55 last edited by
        #23

        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!!!

        1 Reply Last reply
        0

        21/23

        18 Feb 2014, 15:47

        • Login

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