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. How to do multiplication with two values results in one cell Qtablewidget PyQt5

How to do multiplication with two values results in one cell Qtablewidget PyQt5

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 509 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.
  • Y Offline
    Y Offline
    YassineKira
    wrote on last edited by YassineKira
    #1

    Hello,

    I want to make a column 3 of a Qtablewidget as the result of the multiplicaion of 2 other columns: Column 1 X column 2, i want to be automatically in many lines.

    i found a some result in : https://forum.qt.io/topic/74193/qtablewidget-operations-over-columns.

    I need in Python not C++, if anyone can help me please.

    Thanks in advance.

    JonBJ 1 Reply Last reply
    0
    • Y YassineKira

      Hello,

      I want to make a column 3 of a Qtablewidget as the result of the multiplicaion of 2 other columns: Column 1 X column 2, i want to be automatically in many lines.

      i found a some result in : https://forum.qt.io/topic/74193/qtablewidget-operations-over-columns.

      I need in Python not C++, if anyone can help me please.

      Thanks in advance.

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

      @YassineKira
      Your question seems to have nothing to do with the question title of "multiple values". Unless you mean values which are the result of multiplication, which is a different thing!

      QTableWidget is a wrapper around QTableView. It has its own model built-in, but that is hidden from you so you cannot override anything in it. Consequently you will have to use setData() (or setItem()) to explicitly set the desired result in column #3, and if you allow editing of the other columns you will have to set a slot to recalculate whenever those change.

      If you change over to using a QTableView instead you can define your own model. And that way, with subclassing, you can override the data() method so that it always calculates the product, instead of having to call setData(). That's how I would do it.

      We expect people to implement the code for suggestions themselves, not to have to write lines of code for everyone's questions. Still less if you expect a Python sample only. That's what programming is about. If you want to follow the example in the reference you quoted just translate the few lines of C++ into Python, it;s not hard.

      1 Reply Last reply
      1

      • Login

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