#pyqt | Logs for 2019-01-30
Back
[03:00:16] -!- BPL has joined #pyqt
[03:11:32] <BPL> Question, why the disconnected signal won't be emmited here https://stackoverflow.com ?
[07:01:51] -!- Grange has joined #pyqt
[07:08:30] <Grange> Hi all. I'd like to do some validity checking on the user given name to the QTreeWidgetItem. I noticed that QTreeWidgetItem doesn't have setValidator() method, so I do the string check in the slot to the QTreeWidget.itemChanged() signal. The problem is if the validity check fails, it doesn't let me call QTreeWidget.editItem(item) inside this slot. What's the recommended way of reverting to the old name and letting user input again? Code: https://paste.pound-py
[07:08:30] <Grange> thon.org/show/yriVCSU3ZWgb6BqgD18k/
[07:08:36] <Grange> https://paste.pound-python.org
[07:08:47] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[07:09:40] <Grange> Thanks in advance
[07:12:32] -!- daegontaven has joined #pyqt
[07:46:01] <Grange> I somehow managed to do it, by subclassing QItemDelegate and assign it to the QTreeWidget.
[08:19:44] -!- Grange has quit [Remote host closed the connection]
[08:34:52] -!- Grange has joined #pyqt
[08:35:34] <Grange> No that doesn't solve all of my problems. I still need to prevent duplicate names.
[08:47:03] -!- kushal has quit [Remote host closed the connection]
[08:47:22] -!- kushal has joined #pyqt
[09:08:45] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[09:12:38] -!- daegontaven has joined #pyqt
[09:31:27] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[09:37:10] -!- daegontaven has joined #pyqt
[09:42:35] <Grange> I've posted my question to SO (https://stackoverflow.com/questions/54443129/pyqt-validity-check-on-qtreewidgetitem). Any help is greatly appreciated.
[09:53:49] <BPL> Grange: So... question, on which contexts you want to make the validation? Is it the tree static (ie: you can't move items around)? Are you also validating when inserting?
[09:54:33] <BPL> said otherwise, you want to have a "validated/unique" tree at any given time?
[09:56:41] <Grange> BPL, I'd like to allow moving items around. It's intended like a directory tree structure.
[09:57:59] <altendky> that'd be at canDropMimeData afaik
[10:06:38] <altendky> Grange: can't you subclass QValidator and implement anything? when you create it you can pass it the parent index, the edited node index, whatever it needs
[10:06:51] <altendky> or maybe even just the list of all siblings names
[10:11:56] <Grange> altendky, let me give it a try.
[10:31:01] -!- BPL has quit [Ping timeout: 250 seconds]
[10:39:44] <Grange> I think I'm getting somewhere
[10:41:15] <Grange> So I've to give the QTreeWidget a new delegate each time the renaming function is called
[10:45:30] -!- BPL has joined #pyqt
[10:55:00] <Grange> This is what I got so far. The remaining problem is if it detects a sibling conflict (e.g. 'abc' vs 'abc'), I can't type 'c' after 'ab', although it could end up as 'abcd'.
[10:55:04] <Grange> https://paste.pound-python.org
[10:55:40] <altendky> mm, on-the-fly validation, not submission validation :[
[10:59:32] -!- AbleBacon has joined #pyqt
[10:59:57] <altendky> Grange: i'm trying to see if the delegate itself has any hook that could be overridden
[11:00:42] <altendky> Grange: http://doc.qt.io figure out when that is emitted and don't unless it's valid?
[11:01:09] <altendky> Grange: i've got some delegates but i don't have that hooked yet
[11:01:41] <altendky> https://github.com
[11:02:03] <altendky> these are used with my custom not-really-qt-model so the contents of the functions won't really directly fit
[11:14:03] -!- Siecje has joined #pyqt
[11:49:00] <Grange> altendky, I found this SO question regarding the "edit: editting failed" issue, and found that using the `Qt.QueuedConnection` solved my problem
[11:49:10] <Grange> https://stackoverflow.com
[11:51:21] <altendky> Grange: that seems an odd thing to need to do, more like something else is wrong in the setup (unless there's a qt bug report for it i suppose). and i'm not really sure what their Pairs object is.
[11:53:05] <Grange> This is what I got: https://paste.pound-python.org
[11:53:22] <altendky> hmm, i guess it's trying to trigger a new edit before the old is complete and the queued connection (rather than the direct which would be what the automatic connection would do) delays it until the existing edit closes then it opens a new one
[11:54:07] <altendky> Grange: were you not able to find the commit?
[11:54:42] <Grange> what commit?
[11:54:50] <altendky> err, commitData()
[11:54:55] <altendky> sorry
[11:55:14] <altendky> Grange: and what do you want to have happen? i initiate an edit, enter something invalid, press enter... it should fail with a message? just block the commit? fail unchanged?
[11:57:06] <Grange> I'd like to popup a, tooltip perhaps, showing a name conflict, then revert back to the old name, in edit mode
[11:57:30] <altendky> i'd probably leave their existing invalid edit in case they just need to tweak it.
[11:58:53] <altendky> Grange: but it seems like you want the delegate to not commit the data unless it's valid. we just need to figure out where that's normally triggered
[12:01:50] <altendky> Grange: http://doc.qt.io search for commitAndCloseEditor()
[12:01:51] <Grange> altendky, I never worked with delegate before. But I agree that the check should happen after the commit
[12:02:04] <altendky> err, before the commit?
[12:02:32] <altendky> i'm thinking you keep control with the delegate until you have a valid input
[12:03:47] <Grange> now I'm confused...
[12:03:51] <altendky> so they connect the editor's editingFinished to their commitAndCloseEditor. that's pretty straightforward but it seems like something else is already doing a connection for that in yours. not sure how to disable it
[12:08:35] <altendky> Grange: there's http://doc.qt.io which you could override, but i'm not sure how you feed back to the delegate to get the popup. that's the model, not the view, so you don't want to be doing gui stuff there, and you are using a QTreeWidget so you don't have an exlicit model anyways. so i think you need to avoid committing the invalid data. or, accept it and then connect to the standard
[12:08:35] <altendky> item's changed signal and respond to the failure there. but that seems annoyingly late.
[12:10:16] <altendky> but, maybe the last option really is the least intrusive. no custom delegate. just connect to the http://doc.qt.io signal, create the tooltip and reinitiate the edit. though if they cancel then you'll have to catch that and set back to the original original data.
[12:10:56] <Grange> altendky, yes, that's what I was trying to do
[12:14:03] <Grange> I have to leave for now. Many thanks for your help altendky See you later
[12:14:12] <altendky> Grange: good luck
[12:14:20] -!- Grange has quit [Remote host closed the connection]
[12:29:01] -!- kushal has quit [Remote host closed the connection]
[12:29:15] -!- kushal has joined #pyqt
[14:24:56] -!- daegontaven has quit [Ping timeout: 240 seconds]
[15:37:22] <altendky> i'm looking for a stop-gap until i can address the QStandardItemModel i'm using not providing separate edit and display roles (i'd like a `-` shown for empty but 'editable' cells). so i add a QColor to the decoration role... and now the rows in the view are taller to fit the color.
[15:37:39] <altendky> can they not be shrunk?
[15:38:52] -!- daegontaven has joined #pyqt
[15:43:36] -!- daegontaven has quit [Client Quit]
[15:52:32] -!- daegontaven has joined #pyqt
[15:58:44] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[16:00:46] -!- daegontaven has joined #pyqt
[16:34:36] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[16:34:57] -!- daegontaven has joined #pyqt
[16:51:56] -!- mintograde has joined #pyqt
[17:01:40] -!- Siecje has parted #pyqt
[17:16:27] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[17:16:50] -!- daegontaven has joined #pyqt
[17:21:58] -!- BPL has quit [Read error: Connection reset by peer]
[17:22:24] -!- BPL has joined #pyqt
[18:18:50] -!- AbleBacon has quit [Quit: Leaving]
[18:39:24] -!- BPL has quit [Quit: Leaving]
[20:56:26] -!- mintograde has quit [Ping timeout: 268 seconds]
[22:57:38] -!- Mrokii has quit [Ping timeout: 250 seconds]
[23:11:51] -!- Mrokii has joined #pyqt