Python Forum
[PyQt] Pyqt5: How do you make a button that adds new row with data to a Qtablewidget
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Pyqt5: How do you make a button that adds new row with data to a Qtablewidget
#1
My goal is to create a view only table that allows you to add data to table that is then displayed.

Im having trouble with making a script that will actually add a new row to the current amount of rows. Im also having trouble trying to display the data in advance.

Think of it like a program that has a line edit that allows you input whatever into it, then afterwards have a button that displays it on a table.

Thanks in advance!
Reply
#2
It depends on how many columns a row has and in which column it should be inserted.
Reply
#3
(Dec-31-2019, 09:27 AM)Axel_Erfurt Wrote: It depends on how many columns a row has and in which column it should be inserted.

Each column has 3 rows and every column will be filled in each row.
Reply
#4
Okay first you are approaching this in the wrong manner... the data in a QTreeView or QTreeWidget should be stored within your code within a List or Dictionary and any and all manipulation you are doing to the data occurs to this in code List/Dictionary -- then whenever you want you simply update the QTreeView/QTreeWidget with your data.

Either that or you let them add a row to the QTreeView and edit its contents directly but either way the behind the scenes functionality is taking place within your List/Dictionary -- you are just implementing the Editing slightly differently is all.
Reply
#5
(Dec-31-2019, 10:19 PM)Denni Wrote: Okay first you are approaching this in the wrong manner... the data in a QTreeView or QTreeWidget should be stored within your code within a List or Dictionary and any and all manipulation you are doing to the data occurs to this in code List/Dictionary -- then whenever you want you simply update the QTreeView/QTreeWidget with your data.

Either that or you let them add a row to the QTreeView and edit its contents directly but either way the behind the scenes functionality is taking place within your List/Dictionary -- you are just implementing the Editing slightly differently is all.

I understand that but my problem is I don't how to script the data into the QTablewidget because it doesn't display at all if I do so.
Reply
#6
I have an Example on github that loads tab delimited csv into QTableWidget.

Maybe this helps you.
Reply
#7
YoshikageKira Wrote:I understand that but my problem is I don't how to script the data into the QTablewidget because it doesn't display at all if I do so.

Okay you need to clarify this -- what do you mean by "script the data into the QTableWidget" what is it that you are trying to do exactly that you are not able to do -- have you created a MUC (Minimal Usable Code) to experiment with this and if no -- then can you provide a MRE (Minimal Reproducible Example) that shows what you are doing that is not working for you. Either of these two a MUC or MRE posted here will get you a much more efficient as well as quicker answer.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PyQt5 form not displaying my data from SQLite3 Database Linuxdesire 2 4,928 Jan-10-2023, 09:51 PM
Last Post: gradlon93
  [Tkinter] Trying to add data into a shelf from a submit button TWB 8 1,809 Jan-06-2023, 11:30 PM
Last Post: TWB
  [Tkinter] how to make label or button not visible with the place method? nowayj63 2 2,640 Jan-03-2023, 06:29 PM
Last Post: Yoriz
Question [Tkinter] How to make split button? teknixstuff 2 1,019 Jan-03-2023, 06:21 PM
Last Post: Yoriz
  Can't get tkinter button to change color based on changes in data dford 4 3,364 Feb-13-2022, 01:57 PM
Last Post: dford
  [PyQt] QTableWidget print problem JokerSob 8 4,685 Jan-28-2022, 06:08 PM
Last Post: Axel_Erfurt
  [Tkinter] Make my button text update? Skata100 1 2,013 Aug-07-2021, 05:37 AM
Last Post: deanhystad
  [PyQt] How do I display the DB table I will choose from the QComboBox in QTableWidget JokerSob 2 2,272 Aug-05-2021, 03:00 PM
Last Post: JokerSob
  Displaying database info in QTableWidget thewolf 6 5,182 Apr-03-2021, 02:49 PM
Last Post: thewolf
  Button to add data to database and listbox SalsaBeanDip 1 2,807 Dec-06-2020, 10:13 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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