
Originally Posted by
meyrambek
not as txt as xml is more good way
Please have a look at QSettings and you will see that there is no point in using a text file or even an XML file.

Originally Posted by
wysota
Please provide a test case where scrollTo() doesn't work as expected.
Ok, here goes for a very simple example of what I am trying to do with scrollTo():
QTreeView.pro:
QT += core gui
TEMPLATE = app
SOURCES += main.cpp
QT += core gui
TARGET = QTreeView
TEMPLATE = app
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
main.cpp:
#include <QApplication>
#include <QFileSystemModel>
#include <QHeaderView>
#include <QTreeView>
int main(int argc, char *argv[])
{
QFileSystemModel fsm;
fsm.setRootPath(""); // I.e. access to the whole file system
w.setModel(&fsm);
w.
header()->setResizeMode
(QHeaderView::ResizeToContents);
w.show();
QModelIndex mi
= fsm.
index("C:\\Windows\\System32\\zipfldr.dll");
w.setCurrentIndex(mi);
w.scrollTo(mi);
return a.exec();
}
#include <QApplication>
#include <QFileSystemModel>
#include <QHeaderView>
#include <QTreeView>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFileSystemModel fsm;
fsm.setRootPath(""); // I.e. access to the whole file system
QTreeView w;
w.setModel(&fsm);
w.header()->setResizeMode(QHeaderView::ResizeToContents);
w.show();
QModelIndex mi = fsm.index("C:\\Windows\\System32\\zipfldr.dll");
w.setCurrentIndex(mi);
w.scrollTo(mi);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
The idea behind line 21 is that we point to a file which is out of the field of view and should therefore get scrollTo() to scroll down to that file. Unfortunately, this doesn't work for me, as shown below:
QTreeView_scrollTo.png
Bookmarks