Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Design pattern for an inspector widget
Qt 6.11 is out! See what's new in the release blog

Design pattern for an inspector widget

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 648 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joe_climber
    wrote on last edited by
    #1

    Currently, I am making an app with vtk and qt. This app has an inspector (properties) widget. This widget is a qtable and allows the user to edit and see information about the shape that is selected. Currently, I have one huge if statement for when the values are changed in the qtable. I also have a lot of the vtk framework mixed in the widget for when the values are changed. What are some design patterns that could help me reduce the coupling to vtk and reduce the size of my update value function? I'm a novice so anything helps.

    JonBJ 1 Reply Last reply
    0
    • J Joe_climber

      Currently, I am making an app with vtk and qt. This app has an inspector (properties) widget. This widget is a qtable and allows the user to edit and see information about the shape that is selected. Currently, I have one huge if statement for when the values are changed in the qtable. I also have a lot of the vtk framework mixed in the widget for when the values are changed. What are some design patterns that could help me reduce the coupling to vtk and reduce the size of my update value function? I'm a novice so anything helps.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Joe_climber
      Hello and welcome.

      A bit hard to answer because the question is general. You should separate off the "vtx" code from the UI code handling the table changes, not have it mixed in. You might well leverage Qt's signals and slots for this: the UI raises signal(s) when a value is changed and the vtk code is in slots when are run when the signal is emitted. You might do this as each value gets changed in the UI individually, or you might allow the user to change lots of values and then have an "OK" button which emits a single signal and all values are dealt with at one time.

      For the if statement it's a bit harder. You might use a switch statement instead for neatness but that doesn't really change the situation. If you need to do unrelated, different things in vtk for each property it may be unavoidable (unless each UI widget fires a distinct slot for one property).

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved