Results 1 to 4 of 4

Thread: QTreeView no show inside QDockWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Post QTreeView no show inside QDockWidget

    Hi, I want to show are file system using QTreeView on a QDockWidget. Here is my code:

    Qt Code:
    1. QFile file(":/default.txt");
    2. file.open(QIODevice::ReadOnly);
    3. TreeModel model(file.readAll());
    4. file.close();
    5.  
    6. w.setModel(&model);
    7. swatch1->setWidget(&w);
    8. w.setEnabled(true);
    9.  
    10. addDockWidget(leftarea, swatch1);
    To copy to clipboard, switch view to plain text mode 
    swatch1 is of type QDockWidget. The above code is inside a function of MainWindow. The code runs smoothly, and the tree does not show up.

    I also tried another way: putting QTreeView into a QLayout, which in turn be put into QDockWidget. This 2nd code also runs smoothly, and the tree does not show up.

    This code is copied from a working example on Qt Creator IDE, and I tested working. The only difference is, in the original QTreeView example, the above code is placed inside the main() { ..... } function.

    Does anyone has a working example, putting QTreeView into QDockWidget and working? Thanks in advance.
    Last edited by anda_skoa; 11th March 2017 at 11:33. Reason: missing [code] tags

Similar Threads

  1. Replies: 5
    Last Post: 17th March 2017, 01:20
  2. QDockWidget inside QDockWidget
    By mqt in forum Qt Programming
    Replies: 3
    Last Post: 1st July 2013, 13:57
  3. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 08:06
  4. Resizing QDockWidget on Show
    By doggrant in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2009, 14:58
  5. Default size of a QListWidget inside a QDockWidget
    By rakuco in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2007, 09:01

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.