1 of 2 EMIT functions does not work
-
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.cppconnect(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 -_-*
-
@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. -
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.cppconnect(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 -_-*
@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? -
-
@Eligijus said in 1 of 2 EMIT functions does not work:
@bask185 Where do you create Keyboard object?
Mainwindow
-
@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.