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. a button do different job when clicked
Forum Update on Monday, May 27th 2025

a button do different job when clicked

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

    Hi, I want to create a button, that in first click simple run a function (for example).

    void Main::on_pushButton_clicked()
    {
        func();
    }
    

    and in second click, close the program (or maybe send some signal), but I don't know how can I actually do this...
    any one can help me a little with that?
    thanks.

    jsulmJ 1 Reply Last reply
    0
    • S saeid0034

      Hi, I want to create a button, that in first click simple run a function (for example).

      void Main::on_pushButton_clicked()
      {
          func();
      }
      

      and in second click, close the program (or maybe send some signal), but I don't know how can I actually do this...
      any one can help me a little with that?
      thanks.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @saeid0034 Then add a boolean variable which you set to true when on_pushButton_clicked() is called first time. Check that variable: if it is set to true then you know that this is second call...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      6

      • Login

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