Results 1 to 11 of 11

Thread: Under the delegate the data are visible

  1. #1
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Under the delegate the data are visible

    Hi,

    How I can get rid of it?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Can you tell us actually how do you get this?
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Quote Originally Posted by zlatko
    Can you tell us actually how do you get this?
    Yes, of course... I use a delegate which give a possibility to edit the data of the item of treeWidget. The widget of the editing (QSlider) is visible always. When editing through this widget under it the data are visible.

  4. #4
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Can anyone help me?

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

    Default Re: Under the delegate the data are visible

    We'd have to see your modifications to the delegate.

  6. #6
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Quote Originally Posted by wysota
    We'd have to see your modifications to the delegate.
    Ok. It is a declaration:
    Qt Code:
    1. class QLayerListDelegate : public QItemDelegate
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit QLayerListDelegate(QObject *parent = 0)
    7. : QItemDelegate(parent) { ; };
    8.  
    9. virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
    10. const QModelIndex &index) const;
    11. virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
    12. virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
    13. const QModelIndex &index) const;
    14. private slots:
    15. void emitCommitData();
    16. };
    To copy to clipboard, switch view to plain text mode 

    It is extractions from methods which relate to it:
    from createEditor
    Qt Code:
    1. ...
    2. } else if (index.column() == 1) {
    3. TextSlider * slider = new TextSlider(2, parent);
    4. connect(slider, SIGNAL(valueChanged( float )), this, SLOT(emitCommitData()));
    5. ret = dynamic_cast<QWidget*>(slider);
    6. } else if (index.column() == 2) {
    7. ...
    To copy to clipboard, switch view to plain text mode 

    from setEditorData
    Qt Code:
    1. ...
    2. } else if (index.column() == 1) {
    3. TextSlider * slider = qobject_cast<TextSlider*>(editor);
    4. if ( !slider )
    5. return;
    6. slider->setValue(index.model()->data(index).toDouble());
    7. } else if (index.column() == 2) {
    8. ...
    To copy to clipboard, switch view to plain text mode 

    from setModelData
    Qt Code:
    1. ...
    2. } else if (index.column() == 1) {
    3. TextSlider * slider = qobject_cast<TextSlider*>(editor);
    4. if ( !slider )
    5. return;
    6.  
    7. model->setData(index, slider->value());
    8. } else if (index.column() == 2) {
    9. ...
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Under the delegate the data are visible

    You have to reimplement paint() method to leave the cell blank if you use a persistant editor for it.

  8. #8
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    You also could try
    Qt Code:
    1. setAutoFillBackground ( true );
    To copy to clipboard, switch view to plain text mode 
    on the editor widget if implementing paintEvent() is not needed for other stuff.

  9. #9
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Hi guys. Thanks for your answers.
    Quote Originally Posted by orb9
    You also could try
    Qt Code:
    1. setAutoFillBackground ( true );
    To copy to clipboard, switch view to plain text mode 
    on the editor widget if implementing paintEvent() is not needed for other stuff.
    I did thus. Yes, it has helped, but happen a new problem. When the item is selected the highlight is not visible under the editor (see the first attached image)
    Quote Originally Posted by wysota
    You have to reimplement paint() method to leave the cell blank if you use a persistant editor for it.
    I did thus. I reimplemented paint() mathod:
    Qt Code:
    1. void QLayerListDelegate::paint ( QPainter * painter,
    2. const QStyleOptionViewItem & option,
    3. const QModelIndex & index ) const
    4. {
    5. if ( option.state & QStyle::State_Selected ) {
    6. painter->fillRect(option.rect, QBrush(option.palette.highlight()));
    7. } else {
    8. painter->fillRect(option.rect, QBrush(option.palette.base()));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    but the text in other column was gone (see the second attached image). What I can make so as it not happen?
    Attached Images Attached Images

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

    Default Re: Under the delegate the data are visible

    Quote Originally Posted by Mad Max
    but the text in other column was gone (see the second attached image). What I can make so as it not happen?
    Qt Code:
    1. void QLayerListDelegate::paint ( QPainter * painter,
    2. const QStyleOptionViewItem & option,
    3. const QModelIndex & index ) const
    4. {
    5. if(index.column()==3) return;
    6. QStandardItemDelegate::paint(painter, option, index);
    7. }
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Under the delegate the data are visible

    Quote Originally Posted by wysota
    Qt Code:
    1. void QLayerListDelegate::paint ( QPainter * painter,
    2. const QStyleOptionViewItem & option,
    3. const QModelIndex & index ) const
    4. {
    5. if(index.column()==3) return;
    6. QStandardItemDelegate::paint(painter, option, index);
    7. }
    To copy to clipboard, switch view to plain text mode 
    It do help! Thanks Wysota!

Similar Threads

  1. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  2. How to populate delegate with model data.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 09:31
  3. Replies: 1
    Last Post: 22nd October 2007, 02:04
  4. QListView and delegate to display data
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th May 2007, 09:25
  5. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

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.