Results 1 to 12 of 12

Thread: QTreeModel Items to a Widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeModel Items to a Widget

    thats what i tought its qt3 but.. thank you for the link . I want some more examples or explainations , hoping a way to solve this problem.

    baray98

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

    Default Re: QTreeModel Items to a Widget

    If you like the approach then simply port the code. It should take no more than 10 minutes to do it.

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeModel Items to a Widget

    What i would like to do is to draw a widget in tree like fashion ie:

    Device1
    ----------
    | |
    | |----------Device 2
    | |
    | |-------------Device 3
    |
    |
    Device 4
    |_______Device5
    |_______Device 5
    The user can click on the "device widget" and another widget will pop-up showing its signature and some other info that is neccessary. All this widget and the poping widget should all be dynamically build according to the info in my models , by the way i can adjust the data in my model to hold more info to build my widgets.

    Is there any more idea on how to do implement this , I've been reading a lot today and still no idea how will i implement this.

    I dont even know how to draw those device widget in a tree like fashion.

    I am super tired now I have to sleep, talk you later guys
    baray98

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

    Default Re: QTreeModel Items to a Widget

    Can't you implement it like in the example I gave you? It's all there - the "attributes" are your tree items. Simply fetch data from the tree and fill in the dialog. Is there a specific implementation problem you are facing or a simple lack of concept?

    As for the tree - use a tree view with a model that will map devices to nodes. Everything else will be handled by the architecture.

  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeModel Items to a Widget

    I have both problems. yes, I can implement it with the "attributes" style and this will serve as my popping widget everytime my user click on a dvice widget.

    Now, my specific problem for now is that how can i insert a widget as a node in treeview? I wanted it to be a widget so that i can implement the right and left click if I want. I tried the treeview->style()->drawControl() but there is no signal out from widget that i have drawn, where i can connect my showing of my "attributes" widget slot.

    thank you for your insights wyosota...

    baray98

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

    Default Re: QTreeModel Items to a Widget

    It doesn't have to be a widget. You can do it though signals or delegates. See docs for QAbstractItemDelegate and friends.

  7. #7
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeModel Items to a Widget

    all i can see in the delegate is

    Qt Code:
    1. QWidget * createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
    To copy to clipboard, switch view to plain text mode 

    if i will use this then everytim my user trigger the edit then i will pop-up my "attribute" window correct?

    I was thinking of giving my user contextMenu on right click of widget devices and there will be an option like "properties" then show the attribute window. is this doable? is there something i miss on delegates?

    baray98

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

    Default Re: QTreeModel Items to a Widget

    QAbstractItemDelegate::paint() and QAbstractItemDelegate::editorEvent() are the things to look at.

    As for the menu, you can always subclass the widget and reimplement its context menu event, but going through the delegate is fine too.

Similar Threads

  1. transparent background of the main widget
    By nagpalma in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2007, 17:52
  2. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 14:27
  3. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 21:28
  4. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.