1

我想用QLabels 以这种格式显示一些数据

用户名:.....Erich Lancaster(无点)

地点:.......任何地方

有没有办法做到这一点?

4

1 回答 1

3

似乎使用QFormLayout将是最简单的。就像是:

QFormLayout *formLayout = new QFormLayout;
QLabel *usernameLabel = new QLabel("Erich Lancaster");
usernameLabel->setAlignment(Qt::AlignRight);
formLayout->addRow("username:", usernameLabel);

QLabel *locationLabel = new QLabel("Wherever");
locationLabel->setAlignment(Qt::AlignRight);
formLayout->addRow("Location:", locationLabel);
setLayout(formLayout);
于 2012-01-16T18:48:01.827 回答