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. Trouble Connecting Slots
Forum Updated to NodeBB v4.3 + New Features

Trouble Connecting Slots

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 135 Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      1. you cannot connect a signal with less arguments to as slot
      2. 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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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