How to bind signal of item in QAbstractListModel to handler in delegate of ListView
-
I have a QAbstractListModel descendant class with list of instances of my arbitrary type MyItem inside. Also I have a ListView with model binding to that QAbstractListModel descendant.
All I want to do is to bind handler in delegate of ListView to the signal of my arbitrary type MyItem. Is there any way to do it?
UPD. I don't want to bind delegate to signal of a model so when I will have many items all of them will be triggered. I want to notify only one delegate with a signal.
-
Hi,
What do you want to happen with this signal to the delegate ?
-
@SGaist I want to call deselect() on the TextEdit which lives in the delegate. It's the only workaround I found for my issue (to make TextEdit rehighlight itself) from parallel topic https://forum.qt.io/topic/61223/unable-to-get-highlighting-working-on-textedit.
-
What are you highlighting ?
-
@SGaist Just spell errors in red.
After spell-checking is done in separate thread, main model is being notified about results, which are propagated to class, which is accessible through my QSyntaxHighlighter descendant. Then the signal which is connected to rehighlight() is fired. I debugged that rehighligh() is executed, setFormat() is executed as well with correct parameters, but no real highlighting is painted until I interact with the control itself.
I found that calling any method of TextEdit which does nothing in my situation (like deselect()) will cause highlighting to be drawn, so I want to get to that method somehow through signal. I just don't want to fire signal for all items in the model.
-
Can you post a small code sample that helps reproduce this behavior ?
-
@SGaist https://bitbucket.org/ribtoks/rehighlighdemo/src It's very basic (item, main model, worker, highlighter - everything I had), working example similar to my setup. Highlighting works if you click on a TextEdit, but doesn't otherwise.
If you will bother building and running it, click on "Check highlighting" and then on any text field. Also you can notice debug messages about highlighting being applied, but not redrawn. -
It seems it's working on OS X with Qt 5.6
-
@SGaist It's interesting that someone reported at StackOverflow that my test project did work for him in Qt 5.5.1 (I was using 5.4.2 at that moment), but when I upgraded, my main application still didn't work, though it has same code, but a lot of more stuff in main model.
-
Which OS are you on ?