Python Forum
[PyQt] QStyledItemDelegate and QTableView
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QStyledItemDelegate and QTableView
#1
I have subclassed QStyledItemDelegate, reimplemented initStyleOption and set it to a QTableView. Everything works as expected, but I don't understand something. I noticed that on launch of the GUI, the initStyleOption runs 3 full times for one view, however, the __init__ method runs once, as I assumed initStyleOption would (per item in the view/model, of course). Why does it do that?

By printing to console, I noticed that when the GUI loads, initStyleOption gets called once per row in view, then once per item in the view, then again once per item in the view. Is this normal behavior? I'm refraining from sharing code for a couple of reasons, including the code works, and it's a multi-module project and would take a little effort to extract the relevant snippets. I can and will, however, if it helps someone diagnose the "issue" (if it is an issue).

Thanks for any insight.
Reply
#2
Necro-post. Sorry for bad form, but I discovered that running a QStyledItemDelegate in a table is supposed to happen multiple times per view. It is expected behavior. I'm not sure why, but I would assume a reimplemented initStyleOption would be called once for every cell, and then again (and maybe again after that depending on other code. So, it never was an "issue" for me, I just didn't know it is expected.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] PyQt5 QTableView SQLite : edit cell HeinKurz 2 2,286 Mar-27-2023, 10:41 AM
Last Post: HeinKurz
  [PyQt] QTableView set header labels HeinKurz 2 6,422 Jan-23-2023, 08:46 AM
Last Post: HeinKurz
  [PyQt] Determine whether text in QTableView cell is fully visible or not random_nick 0 957 Oct-27-2022, 09:29 PM
Last Post: random_nick
  [PyQt] QTableView: scroll to top cell of the screen random_nick 2 2,766 Oct-08-2022, 12:29 AM
Last Post: random_nick
  [PyQt] [Solved]Add a Blank Row To QTableView Extra 3 5,371 Oct-02-2022, 04:53 PM
Last Post: Extra
  How to update the list of a combo box in a QTableView panoss 10 6,131 Feb-05-2022, 03:24 PM
Last Post: panoss
  [PyQt] How to Copy-Paste a table from Office apps to QTableView? Vittorio 5 7,137 Aug-05-2021, 11:14 AM
Last Post: Axel_Erfurt
  [PyQt] Qtableview adapte size to WBPYTHON 3 11,099 Mar-23-2020, 01:51 AM
Last Post: deanhystad
  [PyGUI] Showing text in QTableView sequence 0 3,030 Jan-20-2019, 05:00 PM
Last Post: sequence
  [PySide2][PyQt5] update QTableView cpuin 0 5,223 Mar-07-2018, 10:20 PM
Last Post: cpuin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020