1 // Copyright Vladimir Prus 2005. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt 4 // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 7 #include <qwidget.h> 8 #include <qpushbutton.h> 9 #include <qapplication.h> 10 11 #include <iostream> 12 13 class My_widget : public QWidget 14 { 15 Q_OBJECT 16 public: My_widget()17 My_widget() : QWidget() 18 { 19 QPushButton* b = new QPushButton("Push me", this); 20 21 connect(b, SIGNAL(clicked()), this, SLOT(theSlot())); 22 } 23 24 private slots: theSlot()25 void theSlot() 26 { 27 std::cout << "Clicked\n"; 28 } 29 30 }; 31 main(int ac,char * av[])32int main(int ac, char* av[]) 33 { 34 QApplication app(ac, av); 35 My_widget mw; 36 mw.show(); 37 app.setMainWidget(&mw); 38 app.exec(); 39 } 40 41 #include "main.moc" 42