Results 1 to 3 of 3

Thread: Help ...QTreeView

  1. #1
    Join Date
    Sep 2009
    Location
    china
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Help ...QTreeView

    I would like to be a sniffer. I have to capture the required data, but data are not binding on the QTreeView...
    Qt Code:
    1. QTreeView* tablepackets=new QTreeView();
    2. model->setHeaderData(0, Qt::Horizontal, QObject::tr("NO."));
    3. model->setHeaderData(1, Qt::Horizontal, QObject::tr("Source IP"));
    4. model->setHeaderData(2, Qt::Horizontal, QObject::tr("Destination IP"));
    5. model->setHeaderData(3, Qt::Horizontal, QObject::tr("Source Port"));
    6. model->setHeaderData(4, Qt::Horizontal, QObject::tr("Destination Port"));
    7. tablepackets->setModel(model);
    8.  
    9. QStandardItemModel* ethmodel=(QStandardItemModel*)tablepackets->Model();
    10. //packet_number is Captured data packets number,and will automatically increase...
    11. item->setText(QString::number(packet_numer));
    12. ethmodel->setItem(packet_number,0,item);
    13. //Other captured data is not displayed
    14. ethmodel->setItem(packet_number,1,new QStandardItem(QString("Protocol")));
    15. .
    16. .
    17. ethmodel->setItem(packet_number,4,new QStandardItem(QString("Port")));
    To copy to clipboard, switch view to plain text mode 
    Please help me ....Thank you...
    Last edited by Raymond; 16th September 2009 at 10:17.

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Help ...QTreeView

    tablepackets->setMode(model); is that a typo? it should be setModel

    anyways as far as your code goes it seems like you can do it easily with QTreeWidget instead of QTreeView

  3. The following user says thank you to nish for this useful post:

    Raymond (17th September 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    china
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Help ...QTreeView

    Quote Originally Posted by MrDeath View Post
    tablepackets->setMode(model); is that a typo? it should be setModel

    anyways as far as your code goes it seems like you can do it easily with QTreeWidget instead of QTreeView
    I'm sorry I was wrong
    Thank you...

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 14:27
  2. One Model, Two Views (QTreeView and QTableView)
    By dgarrett97 in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 19:10
  3. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 22:22
  4. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 07:25
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 15:24

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.