Results 1 to 16 of 16

Thread: QTreeWidget, resizing item and widgets problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QTreeWidget, resizing item and widgets problem

    Quote Originally Posted by The Storm View Post
    @wysota
    1. I don't use QItemDelegate,
    Of course you do. Each cell is painted using a delegate and the default delegate is QItemDelegate or QStyledItemDelegate since Qt 4.4.

    2. I use setAutofillBackground(true) to my QFrame widget if it's that whats you meant but no change...
    Try changing the palette of the frame (especially the Window role) to see if the background of the frame gets painted.

  2. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget, resizing item and widgets problem

    Quote Originally Posted by wysota View Post
    Of course you do. Each cell is painted using a delegate and the default delegate is QItemDelegate or QStyledItemDelegate since Qt 4.4.


    Try changing the palette of the frame (especially the Window role) to see if the background of the frame gets painted.
    I hope that this is what you meant (attached picture) and how can I be sure that this QItemDelegate doesn't paint anything while there is widget on it.
    Attached Images Attached Images

  3. #3
    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: QTreeWidget, resizing item and widgets problem

    Quote Originally Posted by The Storm View Post
    I hope that this is what you meant (attached picture)
    Yes. You can see that the frame doesn't span across the whole item. Could you show us the code for the widget you set as the index widget?

    and how can I be sure that this QItemDelegate doesn't paint anything while there is widget on it.
    Remove the icon when you set the index widget.

  4. #4
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget, resizing item and widgets problem

    Here's the code
    Qt Code:
    1. ContactWidget *pContactWidget = new ContactWidget();
    2. pContactWidget->setAutoFillBackground(true);
    3. /* Setting some data to the QLabels inside the pContactWidget */
    4. pContactView->setItemWidget(selectedItem, 0, pContactWidget);
    To copy to clipboard, switch view to plain text mode 

    ContactWidget - my class that inherits QFrame
    pContactView - this is the QTreeWidget

    Sure removing of the icon from the item before setting the widget fix the problem but this was the thing I want to avoid because when the user click on other contact from the list I must set the icon of the item again and sinse my code is not very well constructed this is ugly task to be done but if there is no other way I will remove that icon before setting the widget.

  5. #5
    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: QTreeWidget, resizing item and widgets problem

    Do you have a hierarchy of items or is your data model flat? Did you modify any properties in ContactWidget? What does the constructor look like?

  6. #6
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget, resizing item and widgets problem

    I don't use model, I'm directly creating new items, I do nothing in to my class that inherits QFrame, thats are future plans but I will show.
    Qt Code:
    1. class ContactWidget : public QFrame
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. ContactWidget(QWidget *parent = 0) : QFrame(parent) {};
    7. ~ContactWidget() {};
    8. };
    To copy to clipboard, switch view to plain text mode 

  7. #7
    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: QTreeWidget, resizing item and widgets problem

    Quote Originally Posted by The Storm View Post
    I don't use model, I'm directly creating new items,
    It's still a data model. So do you organize your items in a flat structure or a graph (parent-child relationship)?

  8. #8
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget, resizing item and widgets problem

    It's flat structure, there is no childs.

  9. #9
    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: QTreeWidget, resizing item and widgets problem

    Could you just for testing issue such code and show us the result?

    Qt Code:
    1. selectedItem->setData(Qt::blue, Qt::BackgroundRole);
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget, resizing item and widgets problem

    Ah I'm sorry but I already do remove the icon before setting the widget and all is fine, so I don't have what to show after I put this line of code, but if you really want to I will make some changes and make screenshot.

Similar Threads

  1. QTreeWidget's Item Widgets
    By jpn in forum Qt Programming
    Replies: 11
    Last Post: 1st April 2006, 23:56

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.