I use QListWidget on Qt Creator of mac, this is my code
m_pListWidget->setObjectName(QStringLiteral("ttmanagevmlist"));
m_pListWidget->setFrameShape(QListWidget::NoFrame);
m_pListWidget->setAttribute(Qt::WA_TranslucentBackground,false);
m_pListWidget->setAlternatingRowColors(true);
m_pListWidget->setContentsMargins(0,0,0,0);
m_pListWidget->setResizeMode(QListView::Fixed);
m_pListWidget->setAutoScroll(true);
m_pListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
But it shows abnormal,like this
It has blue border,but when it loses focus,it's normal. Who knows the reason of the problem?
I believe you can use this:
m_pListWidget->setAttribute(Qt::WA_MacShowFocusRect, false);
Read about Qt::WA_MacShowFocusRect
here
Indicates that this widget should get a QFocusFrame around it. Some widgets draw their own focus halo regardless of this attribute. Not that the QWidget::focusPolicy also plays the main role in whether something is given focus or not, this only controls whether or not this gets the focus frame. This attribute is only applicable to OS X.