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. Button enable signal does not work.

Button enable signal does not work.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 530 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.
  • K Offline
    K Offline
    Kycho
    wrote on last edited by Kycho
    #1

    Hi, I don't know what went wrong.

    1. I set the default of the button to false.
    findButton->setEnabled(false);
    
    1. I connected as below.
    connect(lineEdit, SIGNAL(textChanged(const QString &)),
    this, SLOT(enableFindButton(const Qstring &)));
    

    3.I defined enableFindButton like this.

    void FindDialog::enableFindButton(const QString &text){
        findButton->setEnabled(!text.isEmpty());
    }
    

    But, It is not work.

    What did I do wrong?

    Thanks.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Kycho said in Button enable signal does not work.:

      connect(lineEdit, SIGNAL(textChanged(const QString &)),
      this, SLOT(enableFindButton(const Qstring &)));

      There is a typo (Qstring). You will also get a warning at runtime about this error.
      To avoid this completely I suggest to use the new signal/slot syntax:

      connect(lineEdit, &QLineEdit::textChanged, this, &FindDialog::enableFindButton);

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      6
      • Christian EhrlicherC Christian Ehrlicher

        @Kycho said in Button enable signal does not work.:

        connect(lineEdit, SIGNAL(textChanged(const QString &)),
        this, SLOT(enableFindButton(const Qstring &)));

        There is a typo (Qstring). You will also get a warning at runtime about this error.
        To avoid this completely I suggest to use the new signal/slot syntax:

        connect(lineEdit, &QLineEdit::textChanged, this, &FindDialog::enableFindButton);

        K Offline
        K Offline
        Kycho
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you.
        I've fixed the issue.

        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