Results 1 to 12 of 12

Thread: Split pane view with different headers.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Split pane view with different headers.

    I figured out my problem. In my QSortFilterProxyModel, I had to reimplement all the public methods from my model.

    One other question, do I need to reimplement the mapToSource and mapFromSource in my QSortFilterProxyModel or will the base methods work?

    I ask because I have not reimplemented them and when I set a certain location to expand in the tree view, it is expanding the wrong location in the view, so it's like it's getting the wrong indices for the items.
    Last edited by chocolate; 9th February 2009 at 20:53.

  2. #2
    Join Date
    Feb 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: Split pane view with different headers.

    Okay, any help from anyone will be much appreciated. I've worked through any of the above problems that I had.

    I have a model, a tree proxy model and a table proxy model and two views a tree view and a table view. The Proxy's are based on QSortFilterProxy. The treeview gets the data and displays it (filtered to be only folders). The table view is supposed to only display the data matching it's set parent, for example a users home directory. The treeview/proxy model works fine.

    The problem is that the table view/proxy does not recieve data from the model. If I connect a signal/SLOT on rowsInserted, then I can see that the filter sees the top level data, but does not display anything. In addition, the table proxy model's data method is never called.

    Here are some snippets.
    class MyDataModel : QAbstractItemModel
    class MyTreeProxyModel : QSortFilterProxyModel
    class MyTableProxyModel : QSortFilterProxyModel

    QTreeView *myTreeView;
    QTableView *myTableView;

    In Mainwindow::Mainwindow()

    MyDataModel *dataModel = new MyDataModel();
    // Sets the root directory to display
    dataModel->setRoot("/");
    MyTreeProxyModel *treeProxy = new MyTreeProxyModel();
    MyTableProxyModel *tableProxy = new MyTableProxyModel();

    treeProxy->setSourceModel(dataModel);
    tableProxy->setSourceModel(dataModel);

    // Sets the directory on which to filter..
    tableProxy->setParent("/home/user1");

    myTreeView = new QTreeView();
    myTreeView->setModel(treeProxy);

    myTableView = new QTableView();
    myTableView->setModel(tableProxy);

    QSplitter* splitter = new QSplitter(this);
    splitter->addWidget(myTreeView);
    splitter->addWidget(myTableView);
    setCentralWidget(splitter);

    //This starts the process, i.e. the tree view recieves and displays data
    setRootPath("/home/user1");
    ---------------------------------------

    What I need to do is display a list of folders on one side in a tree and in the other side in tabular form, information about the children of a selected folder. You can think of windows explorer in how it's supposed to behave.

    Example data:
    FOLDERS----------------------------------------- NAME INFO1 INFO2 INFO3

    /folder1------------------------------------------- file1 info1 info2 info3
    /folder2------------------------------------------- file2 info1 info2 info3
    +/home/user1
    /file1
    /file2
    /folder3
    .
    .
    .

    I appreciate any help in advance.

  3. #3
    Join Date
    Feb 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Re: Split pane view with different headers.

    Has anyone seen this or have any ideas? I really need to get this working.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Split pane view with different headers.

    Did you remember to emit appropriate signals from the proxy when "things happen" in the base model?

  5. #5
    Join Date
    Feb 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Split pane view with different headers.

    Yes, I do emit the signal and see that it is emited and received.

    I can also see the data going through the filter, but the tableProxy's data method is never called. The treeproxy's data method is called (although it's just a pass through to the underlying model).

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.