Fix setting of math matrix size with mouse

This commit is contained in:
Yuriy Skalko 2021-02-18 15:36:24 +02:00
parent 99f7d7fa74
commit 110862b09f
2 changed files with 16 additions and 4 deletions

View File

@ -22,10 +22,6 @@
* A simple widget for a quick "preview" in TabularCreateDialog
*/
unsigned int const cellheight = 20;
unsigned int const cellwidth = 30;
EmptyTable::EmptyTable(QWidget * parent, int rows, int columns)
: QTableWidget(rows, columns, parent)
{
@ -34,7 +30,9 @@ EmptyTable::EmptyTable(QWidget * parent, int rows, int columns)
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
viewport()->resize(cellheight * rows, cellwidth * columns);
setSelectionMode(QAbstractItemView::NoSelection);
setFocusPolicy(Qt::NoFocus);
setEditTriggers(QAbstractItemView::NoEditTriggers);
adjustMinCellSize();
}
@ -43,6 +41,16 @@ QSize EmptyTable::sizeHint() const
return QSize(cellwidth * (2 + columnCount()), cellheight * (2 + rowCount()));
}
void EmptyTable::adjustMinCellSize()
{
setRowHeight(0, cellheight);
cellheight = rowHeight(0);
setColumnWidth(0, cellwidth);
cellwidth = columnWidth(0);
}
void EmptyTable::resetCellSize()
{
for(int i = 0; i < rowCount(); ++i)

View File

@ -49,6 +49,10 @@ protected:
virtual void resetCellSize();
private:
void adjustMinCellSize();
int cellheight = 20;
int cellwidth = 30;
};