Solved Trouble Connecting Slots
-
Hello everyone, hope all is well. Currently, I am running into a problem that I have not had up to this point: connecting slots. Usually, when I call the connect method, it works fine. However, for some reason, it is not working. Here is my code.
QLineEdit *announcementText = new QLineEdit(centralwidget); announcementText->setGeometry(QRect(1000, 50, 100, 20); announcementText->setText("There are no announcements at this time."); QPushButton *announcementButton = new QPushButton(centralwidget); announcementButton->setGeometry(QRect(950, 50, 60, 20); connect(announcementButton, SIGNAL(clicked()), this, SLOT (changeAnnouncementText(announcementText);
changeAnnouncementText(QLineEdit aText) is a method that checks to see if the announcement text is the same as its initial text and uses a simple if-else statement to change it to "There are announcements at this time" if needed. My main focus (and believed error) is on the last line of my code:
connect(announcementButton, SIGNAL(clicked()), this, SLOT (changeAnnouncementText(announcementText);
As, when I click on the announcement button in my program nothing happens. What should I do to fix this?
-
Hi,
- you cannot connect a signal with less arguments to as slot
- you cannot pass an argument to the method in the slot macro. There goes the signature of the slot.
You should move to the new style of connection. See the documentation for more information.
-
Hi,
- you cannot connect a signal with less arguments to as slot
- you cannot pass an argument to the method in the slot macro. There goes the signature of the slot.
You should move to the new style of connection. See the documentation for more information.