Add buttons to Vertical Box Layout Panel : QVBoxLayout « Qt « C++






Add buttons to Vertical Box Layout Panel

  

#include <QtGui>

int main(int argc, char* argv[])
{
  QApplication app(argc, argv);
  QWidget *w = new QWidget;
  QHBoxLayout *mainLayout = new QHBoxLayout(w);

  QTextEdit *txtEdit = new QTextEdit(w);
  mainLayout->addWidget(txtEdit);

  QVBoxLayout *buttonLayout = new QVBoxLayout;
  QPushButton *cancelBtn= new QPushButton(QObject::tr("&Cancel"), w);
  QPushButton *okBtn= new QPushButton(QObject::tr("&OK"), w);
  QPushButton *defaultBtn= new QPushButton(QObject::tr("&Default"), w);
  buttonLayout->addWidget(defaultBtn);
  buttonLayout->addWidget(cancelBtn);
  buttonLayout->addWidget(okBtn);
  buttonLayout->addStretch();

  mainLayout->addLayout(buttonLayout);
  w->show();
  return app.exec();
}

   
    
  








Related examples in the same category

1.Vertical BoxLayout