// ---------------------------------------------------------------------- int main(int argc, char** argv) { // Init QApplication app(argc, argv); QWidget wgt; QLabel *text = new QLabel("Хэй!"); QPushButton *abut = new QPushButton("Push me!"); QBoxLayout *Layout = new QBoxLayout(QBoxLayout::TopToBottom); Counter counter; // Building window Layout->addWidget(text, 0,Qt::AlignCenter); Layout->setMargin(10); Layout->addWidget(abut); wgt.setLayout(Layout); wgt.resize(200, 100); wgt.setWindowTitle("Angry Button"); wgt.show(); // Connecting SLOTs and SIGNALs QObject::connect(abut, SIGNAL(clicked()), &counter, SLOT(slotButton()) ); QObject::connect(&counter, SIGNAL(labelChange(QString)), text, SLOT(setText(QString)) ); QObject::connect(&counter, SIGNAL(exit()), &app, SLOT(quit()) ); return app.exec(); }
PathWidgetWithLabel::PathWidgetWithLabel( QString label, int id, QWidget* parent ) : QFrame( parent ), m_id( id ), m_value( QDir( "" ) ) { m_button = new QPushButton( QString( "set dir" ), this ); m_label = new QLabel( label, this ); QVBoxLayout* vLayout = new QVBoxLayout(); QHBoxLayout* hLayout = new QHBoxLayout(); if ( label != "" ) { hLayout->addWidget( m_label ); hLayout->addStretch(); } hLayout->addWidget( m_button ); vLayout->addLayout( hLayout ); QHBoxLayout* hLayout2 = new QHBoxLayout(); m_edit = new QLineEdit( this ); m_edit->setReadOnly( true ); hLayout2->addWidget( m_edit ); vLayout->addLayout( hLayout2 ); hLayout->setContentsMargins( 1, 1, 1, 1 ); hLayout2->setContentsMargins( 1, 1, 1, 1 ); vLayout->setContentsMargins( 0, 0, 0, 0 ); setLayout( vLayout ); connect( m_button, SIGNAL( clicked() ), this, SLOT( slotButton() ) ); setFrameStyle( QFrame::Panel | QFrame::Raised ); setStyleSheet( "QLabel { font: bold 12px } " "QPushButton { font: bold 12px; max-height: 16px; } "); }