Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to load data in column based on previous settings.
Qt 6.11 is out! See what's new in the release blog

How to load data in column based on previous settings.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.2k 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.
  • M Offline
    M Offline
    mady
    wrote on last edited by
    #1

    I am using QTableView to display data available in myfile.csv. It is working fine but I have another requirement which I have no clue:(.

    Problem:
    Let say my table has 20 columns out of them one user is particularly interested in 10 columns, say column# 3,5,9,13,15,....20 and he shifted them together in the table by mouse dragging. Now I wanted to remember this setting for the current session. So that when user will open next CSV file, columns will be automatically arranged as per the last setting. He need not to do anything again.

    Note: I can do it by remembering new column index with actual column index and put the data accordingly but it will be complex. Wondering if any other way is available to achieve the same.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      For storing values obtained in previous sessions typically "QSettings":http://developer.qt.nokia.com/doc/qt-4.8/qsettings.html is used.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I do it this way:

        @
        #include <QHeaderView>

        // to store the state:
        QSettings s;
        s.setValue("TableViewState", ui->tableView->header()->saveState());

        // to restore the state:
        QSettings s;
        QByteArray tvState = s.value("TableViewState").toByteArray();
        if(!tvState.isEmpty())
        ui->tableView->header()->restoreState(tvState);
        @

        http://www.catb.org/~esr/faqs/smart-questions.html

        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