Results 1 to 7 of 7

Thread: Get indices of rows where the signal dataChanged() was emitted

  1. #1
    Join Date
    Oct 2008
    Location
    Aachen
    Posts
    20
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Question Get indices of rows where the signal dataChanged() was emitted

    Hello all,

    I have a model displaying data in a tree view. I implemented a proxy model to show some categories of the tree view in a table view. On my table view, I have on each column different types of items (QComboBox, 3 x QDoubleSpinBox and a QCheckBox). I'm plotting various curves depending on the data in my Table. I'm plotting data stored in the rows and to be able to update my plot, I will like to react to changes in the combo box, the spin boxes and the check box.

    Is there a way to catch the row where a signal whas a emitted or do I need to write a slot that react to the signals
    currentIndexChanged, valueChanged and stateChanged.

    Thanks for your hints,
    Yann
    Last edited by yannwilfried; 6th August 2013 at 13:27.

  2. #2
    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: Get indices of rows where the signal dataChanged() was emitted

    How did you put those widgets there?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2008
    Location
    Aachen
    Posts
    20
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: Get indices of rows where the signal dataChanged() was emitted

    I'm using a custom delegate that inherits QStyledItemDelegate.

    Edit: Your question let me think a bit. Actually I'm using the same delegate between the tree view and the table view since I'm sharing the same model between both views. Wouldn't it be easier to implement a second delegate for the table view and emit myself the signal commitData?
    Last edited by yannwilfried; 6th August 2013 at 13:24.

  4. #4
    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: Get indices of rows where the signal dataChanged() was emitted

    Using QStyledItemDelegate doesn't explain how you put widgets inside item cells. Did you implement all functionality of the widgets yourself or have you used real widgets? If the former then there are no signals there as there are no widgets to emit them. If the latter then I repeat my question -- how did you put those widgets there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2008
    Location
    Aachen
    Posts
    20
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: Get indices of rows where the signal dataChanged() was emitted

    If by real widgets you mean the Qt widgets, I'm just reimplementing the createEditor method and setting my widget at the specified index.
    Last edited by yannwilfried; 6th August 2013 at 13:23.

  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: Get indices of rows where the signal dataChanged() was emitted

    You mean you createEditor returns a QWidget that has e.g. three double spin boxes inside, etc., yes?

    If so then your editor widget (the "top level" widget you return) should expose one or more properties that will be used in setModelData() and setEditorData() to sync the editor and the model. Qt will be able to handle standard property types by itself (assuming the property is marked as a USER property), for non-standard you have to reimplement setModelData and setEditorData and do the syncing yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2008
    Location
    Aachen
    Posts
    20
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: Get indices of rows where the signal dataChanged() was emitted

    I already reimplemented setModelData and setEditorData. I made a basic mistake by handling of the dataChanged() signal that I was invoking like
    Qt Code:
    1. dataChanged(QModelIndex &, QModelIndex &)
    To copy to clipboard, switch view to plain text mode 
    instead of
    Qt Code:
    1. dataChanged(const QModelIndex &, const QModelIndex &)
    To copy to clipboard, switch view to plain text mode 
    .

Similar Threads

  1. QNetworkAccessManager no finished() signal emitted
    By realperson in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2018, 09:42
  2. loadFinished() signal not emitted
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 0
    Last Post: 27th June 2013, 13:21
  3. emitDataChanged and dataChanged signal
    By fruzzo in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2012, 16:47
  4. signal emitted when I zoom
    By mastupristi in forum Qwt
    Replies: 1
    Last Post: 8th July 2009, 18:02
  5. Signal emitted more than once?
    By dbrmik in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 13:44

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.