window: add scrollarea for button grid

This commit is contained in:
Albert S. 2019-08-23 23:42:56 +02:00
parent 69cc2710c3
commit 57bed56dcd

View File

@ -26,6 +26,7 @@
#include <QDebug> #include <QDebug>
#include <QMenu> #include <QMenu>
#include <QClipboard> #include <QClipboard>
#include <QScrollArea>
#include "window.h" #include "window.h"
#include "configprovider.h" #include "configprovider.h"
Window::Window(ConfigProvider &configProvider) Window::Window(ConfigProvider &configProvider)
@ -93,14 +94,20 @@ QVector<EntryPushButton*> Window::generateEntryButtons(const QVector<EntryConfig
void Window::createGui() void Window::createGui()
{ {
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
grid = new QGridLayout(); QScrollArea *sa = new QScrollArea;
lineEdit = new QLineEdit(); grid = new QGridLayout();
vbox->setAlignment(Qt::AlignTop); lineEdit = new QLineEdit();
vbox->addWidget(lineEdit); QWidget *w = new QWidget(this);
vbox->addLayout(grid); w->setLayout(grid);
connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); }); sa->setWidget(w);
connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed); sa->setWidgetResizable(true);
vbox->setAlignment(Qt::AlignTop);
vbox->addWidget(lineEdit);
vbox->addWidget(sa);
connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); });
connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed);
} }
void Window::populateGrid(const QVector<EntryPushButton *> &list) void Window::populateGrid(const QVector<EntryPushButton *> &list)