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. How to disable a button in the slot function?
Forum Updated to NodeBB v4.3 + New Features

How to disable a button in the slot function?

Scheduled Pinned Locked Moved General and Desktop
23 Posts 5 Posters 37.4k 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.
  • R Offline
    R Offline
    Revu
    wrote on last edited by
    #21

    Thank You.It works fine so far it is concerned with button1.When I use button2 I want rest of them to be inactive/disabled.But writing the same code repeatedly by making changes for button that is out of group is complicated.
    Well I tried with window modality as you have mentioned but still could not get the required result.
    Is it possible to check for any active window(by using isActiveWindow) before I click on a button?

    Thank You

    Every fall is to raise higher than Before.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #22

      So, simply disable all buttons like I show above, and re-enable the one button you like to keep enabled?

      @
      #include <QApplication>

      void on_button1_clicked()
      {
      emit enableButton(false);
      button1->setEnabled(true);
      QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
      //do other things that may take serveral seconds

      emit enableButton(true);
      }

      void on_button2_clicked()
      {
      emit enableButton(false);
      button2->setEnabled(true);
      QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
      //do something else that may also take serveral seconds

      emit enableButton(true);
      }
      @

      There are other solutions, of course.

      I don't understand where you're going with your last question. What do you mean that you would like to check what the active window is (what do you mean by that, anyway?) when a button is clicked? That would obviously be the window that button is on then, would it not?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Revu
        wrote on last edited by
        #23

        Yes.Suppose If I have 'Nth' subwindow that is on click of 'Nth' button(All the 'N' buttons are on the same window).In that case,I want all the buttons to be disabled apart from the one I clicked.

        Every fall is to raise higher than Before.

        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