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. 1 of 2 EMIT functions does not work
QtWS25 Last Chance

1 of 2 EMIT functions does not work

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.6k 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.
  • B Offline
    B Offline
    bask185
    wrote on last edited by
    #1

    In my Setup window I want to set the autoRepeatInterval of certain pushbuttons. There are 4 pushbuttons in my mainwindow and there are 4 pushbuttons in the keyboard window. And the ones of my keyboard window aren't getting new values.

    In Setup class I do:

    setup.h
    
    signals:
    void changeInterval(int value);
    void changeIntervalKeyboard(int value);
    
    setup.cpp
    
    void Setup::on_plus_clicked()
    {  
        emit changeIntervalKeyboard(++value);
        emit changeInterval(value);
        ui->intervalLabel->setText(QString::number(value));
    }
    
    void Setup::on_minus_clicked()
    {
        emit changeIntervalKeyboard(--value);
        emit changeInterval(value);
        ui->intervalLabel->setText(QString::number(value));
    }
    

    In mainwindow.cpp:

    connect(settings, &Setup::changeInterval, this, &MainWindow::changeInterval);
    
    void MainWindow::changeInterval(int value)
    {
       ui->DOWN->setAutoRepeatInterval(value);
       ui->UP->setAutoRepeatInterval(value);
       ui->LEFT->setAutoRepeatInterval(value);
       ui->RIGHT->setAutoRepeatInterval(value);
       qDebug() << "i'm @ Mainwindow";
    }
    

    In mainwindow.h

    void changeInterval(int value);
    

    in keyboard.cpp

    connect(settings, &Setup::changeIntervalKeyboard, this, &Keyboard::changeIntervalKeyboard);
    
    
    void Keyboard::changeIntervalKeyboard(int value)
    {
       ui->down->setAutoRepeatInterval(value); // button names are correct
       ui->up->setAutoRepeatInterval(value);
       ui->left->setAutoRepeatInterval(value);
       ui->right->setAutoRepeatInterval(value);
       qDebug() << "I'm @ keyboard";
    }
    

    and in keyboard.h

    void changeIntervalKeyboard(int value);
    

    Whatever I do or try, I am never seeing the debug text: "I'm @ keyboard"
    I tried in keyboard.cpp

    connect(settings, &Setup::changeInterval, this, &Keyboard::changeIntervalKeyboard);
    

    But no effect. I looked at it about ~20 times now but I cannot find any reason why "emit changeIntervalKeyboard(--value);" is not working and why the other one is working. As far as I can see I did the exact same thing for both of them, so now I need others to see... because right now I am not seeing anything anymore -_-*

    VRoninV 1 Reply Last reply
    0
    • E Eligijus

      @bask185 Then just make a connection inside MainWindow like so:
      connect(settings, &Setup::changeIntervalKeyboard, !Keyboard object name!, &Keyboard::changeIntervalKeyboard);
      change !Keyboard object name! to your Keyboard object name.

      B Offline
      B Offline
      bask185
      wrote on last edited by
      #7

      @Eligijus A thnx dat solved the problem

      I'm @ keyboard
      i'm @ Mainwindow
      

      only had to move "void changeIntervalKeyboard(int Value);" from private to public slots.

      1 Reply Last reply
      0
      • B bask185

        In my Setup window I want to set the autoRepeatInterval of certain pushbuttons. There are 4 pushbuttons in my mainwindow and there are 4 pushbuttons in the keyboard window. And the ones of my keyboard window aren't getting new values.

        In Setup class I do:

        setup.h
        
        signals:
        void changeInterval(int value);
        void changeIntervalKeyboard(int value);
        
        setup.cpp
        
        void Setup::on_plus_clicked()
        {  
            emit changeIntervalKeyboard(++value);
            emit changeInterval(value);
            ui->intervalLabel->setText(QString::number(value));
        }
        
        void Setup::on_minus_clicked()
        {
            emit changeIntervalKeyboard(--value);
            emit changeInterval(value);
            ui->intervalLabel->setText(QString::number(value));
        }
        

        In mainwindow.cpp:

        connect(settings, &Setup::changeInterval, this, &MainWindow::changeInterval);
        
        void MainWindow::changeInterval(int value)
        {
           ui->DOWN->setAutoRepeatInterval(value);
           ui->UP->setAutoRepeatInterval(value);
           ui->LEFT->setAutoRepeatInterval(value);
           ui->RIGHT->setAutoRepeatInterval(value);
           qDebug() << "i'm @ Mainwindow";
        }
        

        In mainwindow.h

        void changeInterval(int value);
        

        in keyboard.cpp

        connect(settings, &Setup::changeIntervalKeyboard, this, &Keyboard::changeIntervalKeyboard);
        
        
        void Keyboard::changeIntervalKeyboard(int value)
        {
           ui->down->setAutoRepeatInterval(value); // button names are correct
           ui->up->setAutoRepeatInterval(value);
           ui->left->setAutoRepeatInterval(value);
           ui->right->setAutoRepeatInterval(value);
           qDebug() << "I'm @ keyboard";
        }
        

        and in keyboard.h

        void changeIntervalKeyboard(int value);
        

        Whatever I do or try, I am never seeing the debug text: "I'm @ keyboard"
        I tried in keyboard.cpp

        connect(settings, &Setup::changeInterval, this, &Keyboard::changeIntervalKeyboard);
        

        But no effect. I looked at it about ~20 times now but I cannot find any reason why "emit changeIntervalKeyboard(--value);" is not working and why the other one is working. As far as I can see I did the exact same thing for both of them, so now I need others to see... because right now I am not seeing anything anymore -_-*

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        @bask185 said in 1 of 2 EMIT functions does not work:

        In mainwindow.cpp:
        connect(settings,

        @bask185 said in 1 of 2 EMIT functions does not work:

        in keyboard.cpp
        connect(settings,

        are you sure these 2 settings pointers point to the same object?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bask185
          wrote on last edited by
          #3

          I am not sure, now that you mention I don't think so. 'settings' is the Setup object which is constructed in the MainWindow.h file

          private:
          
          Setup *settings;
          

          I don't know how I can let the keyboard class point at the 'settings' object in the MainWindow.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Eligijus
            wrote on last edited by
            #4

            @bask185 Where do you create Keyboard object?

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bask185
              wrote on last edited by
              #5

              @Eligijus said in 1 of 2 EMIT functions does not work:

              @bask185 Where do you create Keyboard object?

              Mainwindow

              E 1 Reply Last reply
              0
              • B bask185

                @Eligijus said in 1 of 2 EMIT functions does not work:

                @bask185 Where do you create Keyboard object?

                Mainwindow

                E Offline
                E Offline
                Eligijus
                wrote on last edited by
                #6

                @bask185 Then just make a connection inside MainWindow like so:
                connect(settings, &Setup::changeIntervalKeyboard, !Keyboard object name!, &Keyboard::changeIntervalKeyboard);
                change !Keyboard object name! to your Keyboard object name.

                B 1 Reply Last reply
                1
                • E Eligijus

                  @bask185 Then just make a connection inside MainWindow like so:
                  connect(settings, &Setup::changeIntervalKeyboard, !Keyboard object name!, &Keyboard::changeIntervalKeyboard);
                  change !Keyboard object name! to your Keyboard object name.

                  B Offline
                  B Offline
                  bask185
                  wrote on last edited by
                  #7

                  @Eligijus A thnx dat solved the problem

                  I'm @ keyboard
                  i'm @ Mainwindow
                  

                  only had to move "void changeIntervalKeyboard(int Value);" from private to public slots.

                  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