I want to display many widgets in colums and rows(shows as picture),I will not use tablewidget?how to relized it?Thank you.Attachment 13470
Printable View
I want to display many widgets in colums and rows(shows as picture),I will not use tablewidget?how to relized it?Thank you.Attachment 13470
Can QGridLayout draw the grid lines(show as picture ,blue lines) between the Label and Textline?
No. QGridLayout is a layout, not a widget. It has no visual appearance.Quote:
Can QGridLayout draw the grid lines
I think you will probably have to write your own class, based on QWidget, to do this. You could also use the Qt Graphics View Framework, but either way, the amount of work is about the same.
This may scratch your itch depending on how fussy you are about the lines.
Code:
#include "widget.h" #include <QGridLayout> #include <QVBoxLayout> #include <QFrame> #include <QLabel> #include <QLineEdit> { setStyleSheet( QStringLiteral( "QFrame { border: 1px solid blue; } " "QLabel, QLineEdit { padding: 5px; border: 1px solid blue; } " ) ); layout->addWidget(frame); gridLayout->setSpacing(0); gridLayout->setMargin(0); for (int row = 0; row < 4; ++row) { gridLayout->addWidget(label, row, 0); gridLayout->addWidget(edit, row, 1); } } Widget::~Widget() { }