Results 1 to 5 of 5

Thread: Problem with QPushButton setDisabled SLOT

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Problem with QPushButton setDisabled SLOT

    I was trying to find solution on forum but couldn't. The problem is i connected SIGNAL from QComboBox with QPushButton SLOT. I want it to be disabled after changing item from combo list but it doesn't work. When i connect this same SIGNAL with qApp quit() SLOT it works.

    Qt Code:
    1. QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled()));
    To copy to clipboard, switch view to plain text mode 

    Button inherits this SLOT from QWidget but i don't know why in the Qt Designer i cannot see this SLOT.

    Qt Code:
    1. #include <QApplication>
    2. #include <QtCore>
    3. #include <QtGui>
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. QWidget window;
    10. QVBoxLayout *layout = new QVBoxLayout;
    11.  
    12. list << "jeden" << "dwa" << "trzy" << "cztery" << QString::fromUtf8("pięć");
    13.  
    14. QComboBox combo;
    15. combo.addItems(list);
    16.  
    17. QPushButton button(QString::fromUtf8("Wyłącz się do cholery"));
    18.  
    19. window.setLayout(layout);
    20.  
    21. layout->addWidget(&combo);
    22. layout->addWidget(&button);
    23.  
    24. QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled(bool)));
    25. QObject::connect(&button, SIGNAL(clicked()), qApp, SLOT(quit()));
    26.  
    27. window.show();
    28. return app.exec();
    29. }
    To copy to clipboard, switch view to plain text mode 

    it is complete main.cpp

    Ok, what is wrong with this code?
    Last edited by code_err; 8th October 2011 at 17:29.

Similar Threads

  1. QPushButton Signal and QFrame show as a Slot
    By Prophet in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2011, 15:25
  2. qwtplot::setEnabled(false) ignored?
    By liversedge in forum Qwt
    Replies: 1
    Last Post: 7th August 2011, 20:07
  3. Replies: 2
    Last Post: 13th December 2010, 10:31
  4. connect a qpushbutton a slot
    By Lycus HackerEmo in forum Newbie
    Replies: 13
    Last Post: 29th March 2010, 09:14
  5. SLOT and QPushButton
    By mickey in forum Qt Programming
    Replies: 15
    Last Post: 15th February 2006, 06:46

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.