Hi,
I'm using a QListWidget to display some icons vertically. Here is my code:
contentsWidget
->setViewMode
(QListView::IconMode);
contentsWidget
->setMovement
(QListView::Static);
contentsWidget
->setFlow
(QListView::TopToBottom);
contentsWidget
->setIconSize
(QSize(96,
65));
contentsWidget->setMaximumWidth(150);
contentsWidget->setSpacing(12);
contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode);
contentsWidget->setMovement(QListView::Static);
contentsWidget->setFlow(QListView::TopToBottom);
contentsWidget->setIconSize(QSize(96, 65));
contentsWidget->setMaximumWidth(150);
contentsWidget->setSpacing(12);
To copy to clipboard, switch view to plain text mode
My problem is that the icons appears on the left side of the QListWidget and I would like them to be aligned to the center.
At the beginning I naturally thought about changing the alignment in the QListWidget layout:
contentsWidget->layout()->setAlignment(Qt::AlignHCenter);
contentsWidget->layout()->setAlignment(Qt::AlignHCenter);
To copy to clipboard, switch view to plain text mode
And the code compiled. But the application crashed when I ran it...
I have looked probably everywhere in Qt's documentation but I still haven't found what I'm looking for. Does somebody know how to set the alignment properly ?
Bookmarks