Results 1 to 2 of 2

Thread: QSpinbox and mapper

  1. #1
    Join Date
    Jun 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default QSpinbox and mapper

    Hello world, i'm on a problem since 3 days. i have a qtableView and some qlineEdits and qspinbox linked by a qdatawidgetmapper. if i select a row in the model it automatically change the spinbox and the lineEdits. now i want to make the selection on the model in the view change when the qspinbox's value change. thanks in advance...!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSpinbox and mapper

    So connect a slot to the spin box's valueChanged() signal, and use that with QItemSelectionModel::select(), converting the spin box value into a QModelIndex row value:

    Qt Code:
    1. void MyWidget::onValueChanged( int value )
    2. {
    3. QItemSelectionModel * pSelModel = myTableView->getSelectionModel();
    4.  
    5. QAbstractItemModel * pModel = pSelModel->model();
    6. QModelIndex selIndex = pModel->index( value, 0 );
    7. pSelModel->select( selIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Columns );
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. SQL Widget Mapper Example bug?
    By ohmyqt in forum Newbie
    Replies: 0
    Last Post: 28th September 2013, 21:17
  2. Replies: 1
    Last Post: 19th December 2012, 22:24
  3. mapper stop after upgrade to 4.4.3
    By SunnySan in forum Qt Programming
    Replies: 6
    Last Post: 6th November 2008, 11:50
  4. Mapper from QList to QTable* display
    By rwo123gr in forum Newbie
    Replies: 3
    Last Post: 9th May 2008, 20:18
  5. Possible signal mapper problem
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2008, 13:11

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.