#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QScrollArea>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
grid->setAlignment(Qt::AlignTop);
QLabel* label1
= new QLabel("This is a very long label with lots of words that might get cut off with word wrap. Hopefully I have made the label long enough to demonstrate this effect. Maybe I'll ad a few more words.");
label1
->setSizePolicy
(label1
->sizePolicy
().
horizontalPolicy(),
QSizePolicy::Fixed);
label1->setWordWrap(true);
label2->setWordWrap(true);
grid->addWidget(label1, 0, 0);
grid->addWidget(label2, 1, 0);
panelContent->setLayout(grid);
setCentralWidget(panelContent);
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QScrollArea>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget* panelContent = new QWidget;
QGridLayout* grid = new QGridLayout;
grid->setAlignment(Qt::AlignTop);
QLabel* label1 = new QLabel("This is a very long label with lots of words that might get cut off with word wrap. Hopefully I have made the label long enough to demonstrate this effect. Maybe I'll ad a few more words.");
label1->setSizePolicy(label1->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
label1->setWordWrap(true);
QLabel* label2 = new QLabel("This is a short label.");
label2->setWordWrap(true);
grid->addWidget(label1, 0, 0);
grid->addWidget(new QLineEdit, 0, 1);
grid->addWidget(label2, 1, 0);
grid->addWidget(new QLineEdit, 1, 1);
panelContent->setLayout(grid);
setCentralWidget(panelContent);
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Bookmarks