Results 1 to 17 of 17

Thread: inserting QCheckBox into the Header

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default inserting QCheckBox into the Header

    Hello everybody
    I have the task to insert the QCheckBox item into the vertical header.
    I looked through the demos (itemview) where picture (the star) is inserted into the vertical header by reimplementing
    method QVariant QAbstractItemModel::headerData ( int section, Qt::Orientation orientation, int role = Qt:: DisplayRole ) const [virtual]
    Qt Code:
    1. QVariant Model::headerData(int section, Qt::Orientation orientation, int role) const
    2. {
    3. static QIcon services(QPixmap(":/images/services.png"));
    4. if (role == Qt::DisplayRole)
    5. return QString::number(section);
    6. if (role == Qt::DecorationRole)
    7. return qVariantFromValue(services);
    8. return QStandardItemModel::headerData(section, orientation, role);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Then I try to reload this method for my own model (CustomModel)

    Qt Code:
    1. QVariant CustomModel::headerData(int section, Qt::Orientation orientation, int role) const
    2. {
    3. if (role == Qt::DisplayRole)
    4. return QString::number(section);
    5. QObject *object = new QCheckBox;
    6. if (role == Qt::UserRole)
    7. return qVariantFromValue(object);
    8. return QStandardItemModel::headerData(section, orientation, role);
    9. }
    To copy to clipboard, switch view to plain text mode 

    but there is no effect.
    Help me please.
    Last edited by ru_core; 12th April 2008 at 19:30.

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 18:50
  2. Replies: 0
    Last Post: 10th November 2006, 13:46

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.