Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. ListView加载数据后,滚动条无法立即使用
Forum Updated to NodeBB v4.3 + New Features

ListView加载数据后,滚动条无法立即使用

Scheduled Pinned Locked Moved Chinese
3 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Heart_Blue
    wrote on last edited by
    #1

    @ QFileInfo fileinfo = QFileInfo(fileName);

    model->setRootPath(fileinfo.absoluteDir().absolutePath());
    model->setReadOnly(true);

    ui.listView->setModel(model);
    ui.listView->setRootIndex(model->setRootPath(fileinfo.absoluteDir().absolutePath()));
    ui.listView->setCurrentIndex(model->index(fileinfo.absoluteFilePath()));
    ui.listView->scrollToBottom();
    @

    我想在打开一个文件后,用QListView显示该文件目录下的所有文件。

    但是,问题是,我想用滚动条跳到这个文件处,完全没有反应。不过,在我第二次运行到这个地方时,滚动条才会跳转。

    我跟踪了下,发现第一次加载的时候,滚动条的最大值还是0.

    有没有什么办法,能让这个滚动条在第一次读取文件的时候,就自动加载完毕,并实现滚动

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jiangcaiyang
      wrote on last edited by
      #2

      尝试调用QListView::update(),看看有没有效果?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Heart_Blue
        wrote on last edited by
        #3

        [quote author="jiangcaiyang" date="1407981384"]尝试调用QListView::update(),看看有没有效果?[/quote]
        没有反应

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved