C++/Qt/QHBoxLayout

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Using for loop to add widget to Layout

<source lang="cpp">

  1. include <QtGui>

int main(int argc, char *argv[]) {

 QApplication a(argc, argv);
 QWidgetw;
 QHBoxLayout lay(&w);
 QTextEdit *txtEdit = 0;
 for (intstretch = 1;stretch <= 5; stretch++) {
   txtEdit = new QTextEdit(&w);
   lay.addWidget(txtEdit, stretch);
 }
 w.show();
 return a.exec();

}


 </source>