Results 1 to 4 of 4

Thread: QTreeWidget and QTextBrowser working together

  1. #1
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeWidget and QTextBrowser working together

    i am trying to create a simple document browser (html) my 'table of contents' or 'index' i implemented using qtreewidget and my html pages are displayed using qtextbrowser. when i click on a qtreewidgetitem i can update the page in qtextbrowser. but when i click on a href link on a page in the qtextbrowser, i cant figure out an easy way to update the qtree to highlight the new page's qtreewidgetitem. is there a simple solution for this or should i be using different widgets? i tried setting qstring data to the qtreewidgetitems and iterating through the items and if the data == the qurl passed from anchorclicked then select the qtreewidgetitem but i couldnt get that to work.

    any help greatly appreciated as i am new to qt.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeWidget and QTextBrowser working together

    i tried setting qstring data to the qtreewidgetitems and iterating through the items and if the data == the qurl passed from anchorclicked then select the qtreewidgetitem but i couldnt get that to work.
    What is going wrong when you do this, is the search triggered, if triggered does it give no results?

  3. #3
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeWidget and QTextBrowser working together

    i was setting the data to the "filename.html" and the href link from an html page would be the same but the qurl contains the entire path, which can be different for everybody's computer, so we dont want this. I suppose I could try and take only the qurl text after the last "/" but this seems to be getting more finicky than it needs to be. i thought there would be a better or simpler solution since i have seen this type of thing done before.

  4. #4
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeWidget and QTextBrowser working together

    got it working. I set QString data to each QTreeWidgetItem like I said. (the filename.html) then when i iterated the items if the string.contains(newPage) then setSelected(true) else setSelected(false) and it works. Have to be careful though, because for some reason, the items I hadnt set the data yet would also get selected.

Similar Threads

  1. Replies: 2
    Last Post: 17th March 2008, 13:53
  2. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2007, 00:14
  3. Replies: 1
    Last Post: 19th October 2007, 02:29
  4. Use CSS in QTextBrowser
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2006, 19:25
  5. QTreeWidget signal not working
    By Kapil in forum Newbie
    Replies: 6
    Last Post: 28th April 2006, 11:19

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.