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. Signals and slots didn't emitted
Forum Updated to NodeBB v4.3 + New Features

Signals and slots didn't emitted

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 284 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.
  • M Offline
    M Offline
    mimamrafi
    wrote on last edited by
    #1

    Hai everyone, I want to ask something. My code didn't emit to slot, this is my code

    // maingui.h
    public slots :
        void getLimit();
    
    // maingui.cpp
    #include "setlimitvolt.h"
    ...
    MainGUI::MainGUI(QWidget *parent, int type) :
        QWidget(parent),
        ui(new Ui::MainGUI)
    {
        this->limitType = type;
        ui->setupUi(this);
        SetLimitVolt *LimitV = new SetLimitVolt();
        connect(LimitV,SIGNAL(limiting()), this, SLOT(getLimit()));
    }
    
    void MainGUI::getLimit(){
        qDebug() << "test";
    }
    

    and I want to emit my code from other class

    // setlimitvolt.h
    signals :
        void limiting();
    
    // setlimitvolt.cpp
    void SetLimitVolt::on_lineEdit_editingFinished()
    {
        emit limiting();
    }
    

    Is there any wrong code ?

    jsulmJ 1 Reply Last reply
    0
    • M mimamrafi

      Hai everyone, I want to ask something. My code didn't emit to slot, this is my code

      // maingui.h
      public slots :
          void getLimit();
      
      // maingui.cpp
      #include "setlimitvolt.h"
      ...
      MainGUI::MainGUI(QWidget *parent, int type) :
          QWidget(parent),
          ui(new Ui::MainGUI)
      {
          this->limitType = type;
          ui->setupUi(this);
          SetLimitVolt *LimitV = new SetLimitVolt();
          connect(LimitV,SIGNAL(limiting()), this, SLOT(getLimit()));
      }
      
      void MainGUI::getLimit(){
          qDebug() << "test";
      }
      

      and I want to emit my code from other class

      // setlimitvolt.h
      signals :
          void limiting();
      
      // setlimitvolt.cpp
      void SetLimitVolt::on_lineEdit_editingFinished()
      {
          emit limiting();
      }
      

      Is there any wrong code ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mimamrafi Please use new Qt5 connect syntax to make sure the connect succeeded: https://doc.qt.io/qt-5/signalsandslots.html

      Next: you define LimitV in MainGUI and do NOT show it. My guess is that you have another LimitV member in your MainGUI class which you actually want to use. Please show whole MainGUI header file.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      5
      • jsulmJ jsulm

        @mimamrafi Please use new Qt5 connect syntax to make sure the connect succeeded: https://doc.qt.io/qt-5/signalsandslots.html

        Next: you define LimitV in MainGUI and do NOT show it. My guess is that you have another LimitV member in your MainGUI class which you actually want to use. Please show whole MainGUI header file.

        M Offline
        M Offline
        mimamrafi
        wrote on last edited by
        #3

        @jsulm yes you are right , after a few days, I found my code

        SetLimitVolt *LimitV = new SetLimitVolt();
        

        in another void. sorry for this newbie's fault

        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