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. Led Indicator in Qt
Forum Updated to NodeBB v4.3 + New Features

Led Indicator in Qt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k 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.
  • T Offline
    T Offline
    Tannyveer
    wrote on last edited by
    #1

    Hi,
    I want to design led indicator in qt4 i wrote some code cannot work for me
    please find out the bug here the code is:
    @
    void MainWindow::on_pushButton_3_clicked()
    {
    sleep(2);
    green();
    sleep(2);
    red();
    }

    void MainWindow::green()
    {
    ui->pushButton->setIcon(QIcon("/home/ubuntu/green.png"));
    ui->pushButton->setIconSize(QSize(50,50));
    ui->pushButton_2 ->setIcon(QIcon("/home/ubuntu/red_off.png"));
    ui->pushButton_2 ->setIconSize(QSize(50,50));
    }
    void MainWindow::red()
    {
    ui->pushButton->setIcon(QIcon("/home/ubuntu/green_off.png"));
    ui->pushButton->setIconSize(QSize(50,50));
    ui->pushButton_2 ->setIcon(QIcon("/home/ubuntu/red_on.png"));
    ui->pushButton_2 ->setIconSize(QSize(50,50));
    }
    @

    [andreyc EDIT]: Added @ around the code

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tannyveer
      wrote on last edited by
      #2

      @
      void MainWindow::on_pushButton_3_clicked()
      {
      sleep(2);
      green();
      sleep(2);
      red();
      }
      void MainWindow::green()
      {
      ui->pushButton->setIcon(QIcon("/home/ubuntu/green.png"));
      ui->pushButton->setIconSize(QSize(50,50));
      ui->pushButton_2 ->setIcon(QIcon("/home/ubuntu/red_off.png"));
      ui->pushButton_2 ->setIconSize(QSize(50,50));
      }
      void MainWindow::red()
      {
      ui->pushButton->setIcon(QIcon("/home/ubuntu/green_off.png"));
      ui->pushButton->setIconSize(QSize(50,50));
      ui->pushButton_2 ->setIcon(QIcon("/home/ubuntu/red_on.png"));
      ui->pushButton_2 ->setIconSize(QSize(50,50));
      }
      @
      [andreyc EDIT]: Added @ around the code

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

        The code in second post looks the same as in first.

        What problem do you have with this code ?

        I see only one issue so far.
        The sleep() will stop event loop.
        Use QTimer instead.

        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