[Interest] Creating a grid of icons
senseiwa at gmail.com
Thu Sep 6 11:23:31 CEST 2012
Hi again. After trees, now I'm playing with grids.
The objective is simple: create a grid of selectable icons (with text
below), just like Xcode widget in "New Project".
I've tried two approaches: list, and table widget.
It's a simple widget, I'd like to avoid very complicated solutions, like
using a QGridLayout and create my very own widget.
With a table, I wanted to make the appearance good, so I wanted to make
a "regular" grid of three columns, accounting for the scrollbars.
However, if I set the width as follows, I discover that the vertical
scrollbar width is 100px, which is quite false:
tableWidget->setColumnWidth(0, (tableWidget->width() -
tableWidget->verticalScrollBar()->width()) / 3);
qWarning("width %d scroll %d",
OUTPUT: width 581 scroll 100
With a list, I don't know how to obtain an evenly distributed grid, but
if I set the grid size, I have only two columns, not three:
/ 3, 100));
As before, the width of the vertical scrollbar is 100px.
More information about the Interest