-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWordTable.cpp
More file actions
36 lines (33 loc) · 831 Bytes
/
WordTable.cpp
File metadata and controls
36 lines (33 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "WordTable.h"
#include <QHeaderView>
#include <QScrollBar>
WordTable::WordTable(QWidget *parent, int maxCol) : QTableWidget(parent)
{
this->maxCol = maxCol;
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->setShowGrid(false);
this->horizontalHeader()->hide();
this->verticalHeader()->hide();
this->horizontalScrollBar()->hide();
this->verticalScrollBar()->hide();
reset();
}
void WordTable::addWord(QString word)
{
if (col == maxCol) {
row++;
this->model()->insertRow(row);
col = 0;
}
this->setItem(row, col, new QTableWidgetItem(word));
col++;
this->resizeColumnsToContents();
this->resizeRowsToContents();
}
void WordTable::reset()
{
row = 0;
col = 0;
this->setColumnCount(maxCol);
this->setRowCount(1);
}