Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to blink a pushbutton(Solved)
Forum Update on Monday, May 27th 2025

How to blink a pushbutton(Solved)

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 1.6k 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    Hi

    Anyone can comment why the code below cannot blink a pushbutton

    while(5<6)
    connect(&timer1,SIGNAL(timeout()),this,SLOT(setvisible));
    connect(&timer2,SIGNAL(timeout()),this,SLOT(setinvisible));
    }
    void setvisible()
    {
    ui->pb->setvisible(true);
    }

    voi setinvisible()
    {
    ui->pb2->setvisible(false);
    }

    1 Reply Last reply
    0
    • H Offline
      H Offline
      houmingc
      wrote on last edited by
      #2

      while(5<6)
      connect(&timer1,SIGNAL(),this,SLOT (setvisible());
      connect(&timer2,SIGNAL(),this,SLOT (setinvisible());
      }
      void setvisible()
      {
      ui->pb->setvisible(true);
      }

      voi setinvisible()
      {
      ui->pb2->setvisible(false);
      }

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        i use widget to solved it. I don't understand why i have always have to write workaround to solve simple problem.

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

          [quote author="houmingc" date="1414875115"]
          @
          while(5<6) < infinite loop ?
          connect(&timer1,SIGNAL(),this,SLOT (setvisible()); <- why two timers ?
          connect(&timer2,SIGNAL(),this,SLOT (setinvisible()); <- are the timers class variables ?
          }
          void setvisible()
          {
          ui->pb->setvisible(true);
          }

          voi setinvisible()
          {
          ui->pb2->setvisible(false);
          }@
          [/quote]

          Simpler version
          @
          connect(timer,SIGNAL(),this,SLOT (toggleVisibility());
          }
          void toggleVisibility()
          {
          ui->pb->setVisible(!ui-->pb->isVisible());
          }
          @

          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
          0

          • Login

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