Results 1 to 7 of 7

Thread: disable myself when clicked

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    40
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: disable myself when clicked

    Quote Originally Posted by aamer4yu View Post
    does ur cod reach the slot ?
    Are you using your own slot ? or is it the default slot : on_XXXX_clicked() ?

    BTW, how do you plan to enable it again ? bec you wont be able to click a disabled button
    the setEnabled() kind of functions do not reflect the change till the slot is complete and control goes back to event loop. and as explained below by others, if the only thing you have to do is to disable/enable the button, best is to connect it to the button's slot

    cheers!
    Let your work talk for you

  2. #2
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    21
    Thanked 3 Times in 3 Posts

    Default Re: disable myself when clicked

    i created a test project like this:
    Qt Code:
    1. connect(ui.btn, SIGNAL(clicked()), this, SLOT(on_btn_clicked()));
    2. connect(ui.btn_2, SIGNAL(clicked()), this, SLOT(on_btn_2_clicked()));
    3. //...
    4. THIS::on_btn_clicked()
    5. {
    6. ui.btn->setEnabled(false);
    7. ui.btn_2->setEnabled(true);
    8. }
    9. THIS::on_btn_2_clicked()
    10. {
    11. ui.btn_2->setEnabled(false);
    12. ui.btn->setEnabled(true);
    13. }
    To copy to clipboard, switch view to plain text mode 

    and it works well. my connections are more complicated: like this:
    Qt Code:
    1. //calendar is a QCalendarWidget, currentPageChanged(int, int ) is it's signal, this signal is //often emitted the same time the QPushButton prevMonth and nextMonth is clicked
    2. //currentPageChagned(int,int ) is not triggered by the buttons' clicking
    3. //on_currentPage_changed(int, int) is my slot
    4. void MyWidget::on_currentPage_changed(int, int)
    5. {
    6. prevMonth->setEnabled(false);
    7. nextMonth->setEnabled(true);
    8. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: disable myself when clicked

    Looks, like you could have a look at QWizard...

    Lykurg

Similar Threads

  1. How to disable NextButton in QWizard ?
    By litroncn in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 08:05
  2. Replies: 1
    Last Post: 21st April 2008, 23:43
  3. disable clicked() signal
    By mattia in forum Newbie
    Replies: 2
    Last Post: 27th February 2008, 11:27
  4. Replies: 10
    Last Post: 27th January 2006, 19:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.