[Interest] Creating a grid of icons

Joseph Crowell joseph.w.crowell at gmail.com
Thu Sep 6 14:33:20 CEST 2012


QListWidget/QListview should be the proper way to do this but currently 
it isn't acting as expected in left to right (text below icon) mode in 
Qt5. I was just about to create a bug report for this.

On 9/6/2012 7:23 PM, Sensei wrote:
> 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",
> newProjectDialog.tableWidget->width(),
> newProjectDialog.tableWidget->verticalScrollBar()->width());
>
>
> 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:
>
>   
> newProjectDialog.listWidget->setGridSize(QSize(newProjectDialog.listWidget->width()
> / 3, 100));
>
> As before, the width of the vertical scrollbar is 100px.
>
>
>
> Any suggestions?
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list