This may scratch your itch depending on how fussy you are about the lines.
Qt Code:
  1. #include "widget.h"
  2.  
  3. #include <QGridLayout>
  4. #include <QVBoxLayout>
  5. #include <QFrame>
  6. #include <QLabel>
  7. #include <QLineEdit>
  8.  
  9. Widget::Widget(QWidget *parent)
  10. : QWidget(parent)
  11. {
  12. setStyleSheet(
  13. QStringLiteral(
  14. "QFrame { border: 1px solid blue; } "
  15. "QLabel, QLineEdit { padding: 5px; border: 1px solid blue; } "
  16. )
  17. );
  18. QVBoxLayout *layout = new QVBoxLayout(this);
  19. QFrame *frame = new QFrame(this);
  20. layout->addWidget(frame);
  21.  
  22. QGridLayout *gridLayout = new QGridLayout(frame);
  23. gridLayout->setSpacing(0);
  24. gridLayout->setMargin(0);
  25.  
  26. for (int row = 0; row < 4; ++row) {
  27. QLabel *label = new QLabel(QString("Row %1").arg(row), this);
  28. QLineEdit *edit = new QLineEdit(this);
  29. gridLayout->addWidget(label, row, 0);
  30. gridLayout->addWidget(edit, row, 1);
  31. }
  32. }
  33.  
  34. Widget::~Widget()
  35. {
  36. }
To copy to clipboard, switch view to plain text mode