Results 1 to 7 of 7

Thread: [itemview] delegation to a dialog ...

  1. #1
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default [itemview] delegation to a dialog ...

    Hi
    I have data in a tableview and for some column,
    I need to edit a cell via a dialog.
    Deriving from QItemDelegate and implementing
    * createEditor to return a modal dialog
    * setEditorData to extract the structured data from the variant and put it on the dialog
    * setModelData to take back the structure data from the dialog and put it back in the variant in the model,
    I have quite all right *except* that setModelData is not executed straight away after
    the dialog disappears. Only when I click back on the tableview...

    Anybody has an hint on how to do that kind of thing ?
    Should I use an intermediate button as a proxy editor in the cell (my user may not like this indirection) ?

    Thanks in advance. Regards.

  2. #2
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [itemview] delegation to a dialog ...

    I tested the way of the intermediate button,
    but I still have to pressed enter or tab or click sideway after dialog quits in order to get
    setModelData called
    What I did :
    1. in createEditor : instanciate a special push button that can carry a QVariant and which clicked() signal is connected to a method of my itemdelegate
    2. in setEditorData : I put the qvariant onto the button
    3. in the slot for clicked(), i setup the dialog with the qvariant, exec the dialog
      and on accept i copy dialog qvariant to special button, waiting for setModelData
      to keep clean and then emitting commitData and closeEditor
    4. in setModelData I call setData with the qvariant on the special button

    The problem is my emit of commitData is vain : my setModelData
    is called ony when I as a user interact with the table.

    I feel likeI am gonna gruik --pig noise-- by keeping the index in the special button and use it to call setData with

    Anybody a hint ?
    It seems that many things require a user interaction to be taken into account : calling reset from my model isi not enough to have my tableview repainted

    Have a nice week end .

  3. #3
    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: [itemview] delegation to a dialog ...

    Why not call setData directly from the dialog and ignore the rest? You could even do it simpler if you uset setItemWidget on the view when acting upon change of the current item.

  4. #4
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [itemview] delegation to a dialog ...

    Hi Wysota
    Quote Originally Posted by wysota View Post
    Why not call setData directly from the dialog and ignore the rest? You could even do it simpler if you uset setItemWidget on the view when acting upon change of the current item.
    Why not ? This was my last proposition, with the need to keep the index to setData in.
    I could not find setItemWidget in QTableView.
    Regards.

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

    Default Re: [itemview] delegation to a dialog ...

    Quote Originally Posted by lauranger View Post
    I could not find setItemWidget in QTableView.
    The corresponding method for model-view classes is QAbstractItemView::setIndexWidget().
    J-P Nurmi

  6. #6
    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: [itemview] delegation to a dialog ...

    Quote Originally Posted by lauranger View Post
    Hi Wysota
    Why not ? This was my last proposition, with the need to keep the index to setData in.
    I didn't say to do that from setModelData...
    Quote Originally Posted by jpn View Post
    The corresponding method for model-view classes is QAbstractItemView::setIndexWidget().
    Right... Sometimes it's good to take a look at the docs before you write about some method

  7. #7
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [itemview] delegation to a dialog ... (solved)

    Hi again
    For my second attempt, the one with the button, I am the one to blame :
    I use my own sub-delegate and I "forgot" to relay the signals commitData
    and closeEditor, as it is done when a view registers its delegate.
    Sorry for the annoyance.
    Regards

Similar Threads

  1. how to create a popup dialog
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2006, 16:40
  2. Replies: 3
    Last Post: 23rd July 2006, 18:02
  3. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22
  4. Dialog positioning in GNOME
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 09:41
  5. Shape-changing dialog with qt4.1
    By moe in forum Qt Tools
    Replies: 3
    Last Post: 2nd February 2006, 10:12

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.