我的init非常标准.
// see model for implementing logic of drag this->vIEwport()->setAcceptDrops(allowDrop); this->setDragEnabled(allowDrag); this->setDropIndicatorShown(true); this->m_model->allowDrop(allowDrop);
我不知道为什么我没有看到指标.样式表与视图一起使用,可能就是原因.但是,我已经禁用了样式表,但仍然没有看到它.
视图使用整行进行选择,不确定这是否会导致问题.所以任何暗示都值得赞赏.
– 编辑 –
截至下面的评论,尝试了所有选择模式:单,多或扩展,没有视觉效果.也试过细胞而不是行选择,再没有任何改进.
– 编辑2 –
目前正在评估another style proxy example,类似于下面的那个,最初引用here
– 相关 –
QTreeView draw drop indicator
How to highlight the entire row on mouse hover in QTableWidget: Qt5
https://forum.qt.io/topic/12794/mousehover-entire-row-selection-in-qtableview/7
https://stackoverflow.com/a/23111484/356726
>如果您是QTreeVIEw的子类,则可以覆盖其paintEvent()方法.它默认调用drawTree()方法和paintDropIndicator()一个(后者是QAbstractItemVIEw私有类的一部分).
你可以从paintEvent()调用drawTree(),它也应该覆盖默认的拖放指示器:
class MyTreeVIEw : public QTreeVIEw{public: explicit MyTreeVIEw(QWidget* parent = 0) : QTreeVIEw(parent) {} voID paintEvent(QPaintEvent * event) { QPainter painter(vIEwport()); drawTree(&painter,event->region()); }};
>另一种方法是子类QProxyStyle并覆盖drawPrimitive()方法.当您将元素qstyle :: PE_IndicatorItemVIEwItemDrop作为参数获取时,您可以按照自己的方式绘制它.
代码如下所示:
class MyOwnStyle : public QProxyStyle{public: MyOwnStyle(qstyle* style = 0) : QProxyStyle(style) {} voID drawPrimitive(PrimitiveElement element,const qstyleOption* option,QPainter* painter,const QWidget* Widget) const { if (element == qstyle::PE_IndicatorItemVIEwItemDrop) { //custom paint here,you can do nothing as well Qcolor c(Qt::white); QPen pen(c); pen.setWIDth(1); painter->setPen(pen); if (!option->rect.isNull()) painter->drawline(option->rect.topleft(),option->rect.topRight()); } else { // the default style is applIEd QProxyStyle::drawPrimitive(element,option,painter,Widget); } }};总结
以上是内存溢出为你收集整理的c – 为什么我在QTableView中看不到掉落指示器?全部内容,希望文章能够帮你解决c – 为什么我在QTableView中看不到掉落指示器?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)