Results 1 to 3 of 3

Thread: Modelbased-Itembased types.

  1. #1
    Join Date
    Jul 2007
    Posts
    104
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default Modelbased-Itembased types.

    The real problem is that:How can we change values on form.
    Which type widget will I use?
    Model based?
    Item based?
    I used treeWidget.But on treeWidget I cant click any items or input any values.Only If I use a dialog etc and get value from it I can change using setText(col,value) at background.
    I want to validate columns using QRegExpValidator.So each row-column will be different?
    Last edited by hgedek; 3rd September 2007 at 10:30.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: QTreeWidget-select treeWidgetItem column

    J-P Nurmi

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Modelbased-Itembased types.

    Please do not edit a question to something completely different after it has already been answered.

    You can validate items like this:
    Qt Code:
    1. class MyItemDelegate : public QItemDelegate
    2. {
    3. public:
    4. MyItemDelegate(QObject* parent = 0) : QItemDelegate(parent) {}
    5.  
    6. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
    7. {
    8. QWidget* editor = QItemDelegate::createEditor(parent, option, index);
    9. if (QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(editor))
    10. {
    11. // check column in question from index.column() if needed
    12. // lineEdit->setValidator(...);
    13. }
    14. return editor;
    15. }
    16. };
    17.  
    18. // usage:
    19. treeWidget->setItemDelegate(new MyItemDelegate(treeWidget));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. QTreeWidget - Making a Column editable.
    By Preeteesh in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2007, 13:02
  2. QTreeWidget item editing: want column specificity
    By McKee in forum Qt Programming
    Replies: 12
    Last Post: 10th December 2006, 23:12
  3. Replies: 1
    Last Post: 21st September 2006, 11:37
  4. Sql Server cannot retrieve data from select
    By Atomino in forum Qt Programming
    Replies: 10
    Last Post: 7th September 2006, 17:37
  5. Change column width in a QTreeWidget
    By mace in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2006, 13:19

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.