2016-06-29 58 views
1

我用QListWidget在Mac上的Qt Creator的,这是我的代码QListWidget在Mac OS X显示异常

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); 

但它显示不正常,像这样

enter image description here

它有蓝色边框,但是当它失去焦点时,这很正常。谁知道问题的原因?

+0

介意解释在这种情况下*异常*的含义? – maxik

+0

不,我的意思是它有一个蓝色的边框,但这个问题已经解决,该方法是demonlus的答案 – bai

回答

0

我相信你可以使用这个:

m_pListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); 

阅读Qt::WA_MacShowFocusRecthere

表明这个窗口部件应该得到它周围的QFocusFrame。无论此属性如何,某些小部件都会绘制自己的焦点晕圈。并不是说QWidget :: focusPolicy在确定是否有焦点方面也起着主要作用,它只控制是否获得焦点框架。此属性仅适用于OS X.

+0

谢谢,它的工作原理 – bai