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 #include <qwidget.h> 7 #include <qpushbutton.h> 8 #include <qapplication.h> 9 10 #include <iostream> 11 12 class My_widget : public QWidget 13 { 14 Q_OBJECT 15 public: My_widget()16 My_widget() : QWidget() 17 { 18 QPushButton* b = new QPushButton("Push me", this); 19 20 connect(b, SIGNAL(clicked()), this, SLOT(theSlot())); 21 } 22 23 private slots: theSlot()24 void theSlot() 25 { 26 std::cout << "Clicked\n"; 27 } 28 29 }; 30 main(int ac,char * av[])31int main(int ac, char* av[]) 32 { 33 QApplication app(ac, av); 34 My_widget mw; 35 mw.show(); 36 app.exec(); 37 } 38 39 #include "main.moc" 40