Results 1 to 3 of 3

Thread: How to set data from combobox delegate into 2 cells?

  1. #1
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to set data from combobox delegate into 2 cells?

    Hi all,

    I have a problem figuring out how to set numeric data into another cell, the first left one of the current cell.
    Code is like the spinbox example

    My code holds the combobox delegate, it is connected to some column cells.
    When I enter to select item from the combobox and then leaving, the text gets pasted into the cell -fine. However I want to save a numeric value, the combobox index into another cell.
    Here lays my problem I don't know how to get the cell to the left of the current cell, and how to be able to paste the index number to the cell.


    any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to set data from combobox delegate into 2 cells?

    When your delegate's editor finishes editing, the delegate's setModelData() is being called to store the data into the model.

    You can chose any method of working with the mode in there, including calling the model's setData() for more than one index.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set data from combobox delegate into 2 cells?

    Hi anda_skoa, thks for reply.

    As you suggests, my solution is to put it in the setModelData
    From the input parameters I simply use the model and index.

    QModelIndex indx = model->index(index.row(), index.column() -1);
    model->setdata(indx, comboData->currentIndex(), Qt::EditRole);

    Thks
    /anders

Similar Threads

  1. Replies: 1
    Last Post: 22nd September 2011, 06:33
  2. set combobox delegate on some view items
    By GrahamLabdon in forum Newbie
    Replies: 0
    Last Post: 8th March 2011, 14:36
  3. How to get index of a combobox delegate selection
    By vieraci in forum Qt Programming
    Replies: 12
    Last Post: 21st July 2009, 16:37
  4. Combobox Delegate 25.000 records
    By aekilic in forum Qt Programming
    Replies: 9
    Last Post: 29th July 2008, 12:26
  5. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12

Tags for this Thread

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.