diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 00179c7aef..c8ffe8bde2 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -514,10 +514,17 @@ void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, void TableViewLastColumnResizingFixer::resizeColumn(int nColumnIndex, int width) { - tableView->setColumnWidth(nColumnIndex, width); - tableView->horizontalHeader()->resizeSection(nColumnIndex, width); + int nTableWidth = tableView->horizontalHeader()->width(); + int nColumnsWidth = getColumnsWidth() - tableView->horizontalHeader()->sectionSize(nColumnIndex) + width; + + + if (nColumnsWidth <= nTableWidth && nColumnIndex != tableView->horizontalHeader()->count() - 1) { + tableView->setColumnWidth(nColumnIndex, width); + tableView->horizontalHeader()->resizeSection(nColumnIndex, width); + } } + int TableViewLastColumnResizingFixer::getColumnsWidth() { int nColumnsWidthSum = 0; @@ -546,17 +553,21 @@ int TableViewLastColumnResizingFixer::getAvailableWidthForColumn(int column) void TableViewLastColumnResizingFixer::adjustTableColumnsWidth() { disconnectViewHeadersSignals(); - resizeColumn(lastColumnIndex, getAvailableWidthForColumn(lastColumnIndex)); - connectViewHeadersSignals(); int nTableWidth = tableView->horizontalHeader()->width(); - int nColsWidth = getColumnsWidth(); - if (nColsWidth > nTableWidth) - { - resizeColumn(secondToLastColumnIndex,getAvailableWidthForColumn(secondToLastColumnIndex)); - } + int nColumnCount = tableView->horizontalHeader()->count(); + int nTotalWidth = getColumnsWidth(); + + int firstColumnWidth = nTableWidth * 0.3; + int secondColumnWidth = nTableWidth * 0.3; + + resizeColumn(0, firstColumnWidth); + resizeColumn(1, secondColumnWidth); + + connectViewHeadersSignals(); } + // Make column use all the space available, useful during window resizing. void TableViewLastColumnResizingFixer::stretchColumnWidth(int column) {