Git Product home page Git Product logo

Comments (4)

muyr avatar muyr commented on August 11, 2024

经测试,是 QListView.setResizeMode(QtWidgets.QListView.Adjust) 的锅,每次窗口大小修改,需要重新计算布局(每行多少个)

from dayu_widgets.

muyr avatar muyr commented on August 11, 2024

https://code.qt.io/cgit/qt/qtbase.git/plain/src/widgets/itemviews/qlistview.cpp
源码里面已经做了延迟(0.1秒) layout 处理了,所以我们在放大窗口的时候,可以明显看到一个白色背景(我们ListView是个深色背景,没有立马跟着变大),所以,要么我们加大延迟,则白边效果会更显著;要么我们就搞分页;

void QListView::resizeEvent(QResizeEvent *e)
{
    Q_D(QListView);
    if (d->delayedPendingLayout)
        return;

    QSize delta = e->size() - e->oldSize();

    if (delta.isNull())
      return;

    bool listWrap = (d->viewMode == ListMode) && d->wrapItemText;
    bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
                                || (d->flow == TopToBottom && delta.height() != 0);

    // We post a delayed relayout in the following cases :
    // - we're wrapping
    // - the state is NoState, we're adjusting and the size has changed in the flowing direction
    if (listWrap
        || (state() == NoState && d->resizeMode == Adjust && flowDimensionChanged)) {
        d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout
    } else {
        QAbstractItemView::resizeEvent(e);
    }
}

from dayu_widgets.

reinalin avatar reinalin commented on August 11, 2024

之前我用原生listview的时候用的方法是直接在listveiw的resizeEvent中用listview的setSpacing和setGridSize效果倒是不会出现卡的现象,下面这个视频里面也是100多个的图标
视频

from dayu_widgets.

muyr avatar muyr commented on August 11, 2024

确实一个人精力有限,只能考虑一般情况。
非常欢迎你贡献代码,这里有 如何贡献代码 的步骤

from dayu_widgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.