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. Get bool result of qButton when this is pressed

Get bool result of qButton when this is pressed

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 240 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.
  • I Offline
    I Offline
    Isidro Perla
    wrote on last edited by
    #1

    Hello, i need help to obtain the boolean result in a if conditional of a button state.

    I have a var called restart, and i need to save a bolean value when i press the button, if is pressed i will save true, if it´s not pressed i will save false.

    I need that, because i'm sending in the constructor the value of restart, and i need to capture the moment when is true, becuase later when I release the button the value will be false.

    void MainWindow::on_btn_restart_pressed()
    {
    restart=true;
    myOGLW = new MyOpenGLWidget(m_sB,k_sB,b_sB,t_cB,pauser,restart,opc);
    }

    I hope that can you help whit this!!

    Pl45m4P 1 Reply Last reply
    0
    • I Isidro Perla

      Hello, i need help to obtain the boolean result in a if conditional of a button state.

      I have a var called restart, and i need to save a bolean value when i press the button, if is pressed i will save true, if it´s not pressed i will save false.

      I need that, because i'm sending in the constructor the value of restart, and i need to capture the moment when is true, becuase later when I release the button the value will be false.

      void MainWindow::on_btn_restart_pressed()
      {
      restart=true;
      myOGLW = new MyOpenGLWidget(m_sB,k_sB,b_sB,t_cB,pauser,restart,opc);
      }

      I hope that can you help whit this!!

      Pl45m4P Online
      Pl45m4P Online
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Isidro-Perla

      Use signals & slots to send a signal to your MyOpenGLWidget which will cause a restart.
      https://doc.qt.io/qt-5/signalsandslots.html

      Something like this (in your MainWindow)

      connect(ui->pushbutton_restart, &QPushButton::clicked, myOGLW, &MyOpenGLWidget::restart);
      

      Then, make your widget reset / restart itself (in myOpenGLWidget class)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      3

      • Login

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