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. Dialog close() function not showing?
Qt 6.11 is out! See what's new in the release blog

Dialog close() function not showing?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.5k 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.
  • A Offline
    A Offline
    Archy
    wrote on last edited by
    #1

    Hi, I'm really new to qt so I like experimenting even if its not within the tutorial I'm working on just for more expireince.

    I tried to set a push button to close the window but couldn't connect the signal clicked() to the slot close(), the close function wasn't showing up, furthermore I tried to connect them using this code:

    connect(ui->pushButton_2, SIGNAL(clicked(bool)), this, SLOT(this->close()));
    

    but that code doesn't work, it only compiles and theres still a red line as if thats an error which it may I'm not sure.
    after that I went to the on_pushButton_2_clicked() slot and wrote in the function

    this->close();
    

    which worked fine, can anyone explain why the slot wasn't showing up when I was trying to connect them with the ui window and why my connect function isn't working?

    Taz742T 1 Reply Last reply
    0
    • A Archy

      Hi, I'm really new to qt so I like experimenting even if its not within the tutorial I'm working on just for more expireince.

      I tried to set a push button to close the window but couldn't connect the signal clicked() to the slot close(), the close function wasn't showing up, furthermore I tried to connect them using this code:

      connect(ui->pushButton_2, SIGNAL(clicked(bool)), this, SLOT(this->close()));
      

      but that code doesn't work, it only compiles and theres still a red line as if thats an error which it may I'm not sure.
      after that I went to the on_pushButton_2_clicked() slot and wrote in the function

      this->close();
      

      which worked fine, can anyone explain why the slot wasn't showing up when I was trying to connect them with the ui window and why my connect function isn't working?

      Taz742T Offline
      Taz742T Offline
      Taz742
      wrote on last edited by
      #2

      @Archy
      remove bool and try.

      SIGNAL(clicked())

      Do what you want.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Archy
        wrote on last edited by
        #3

        it still doesn't work :/

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

          Hi,

          @Archy said in Dialog close() function not showing?:

          connect(ui->pushButton_2, SIGNAL(clicked(bool)), this, SLOT(this->close()));

          This is wrong, the SLOT macro expects a slot signature. Remove the this-> from it.

          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
          4

          • Login

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