rowCount() #necessary even when there are no rows in the table. dev. mytable = self. 1. Returns the item for the given row and column if one has been set; otherwise returns 0. setFlags( Qt. fontMetrics(). It moves the scroll bar only to the beginning of the last row inserted which is not always necessarily the bottom of the table because sometimes the height of the last row inserted is really large. I prefer this over the popup from a user perspective. setFixedWidth(15) table. How can I change the code to incorporate that? How can I change the code to incorporate that? The row and column specified is the cell that was clicked. You can set the column name using the setHorizontalHeaderLabels as described below: Nov 19, 2013 · 1. Apr 9, 2020 · 3. This example will mainly be featuring the below method, setItem(). ID = self. #1. 2 and pyqt 4 Oct 16, 2011 · def contextMenuEvent(self, event) ''' The super function that can handle each cell as you want it'''. Is there a way to change this behavior to single click Jun 29, 2016 · Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in the first column, then 3-digit numbers in the two last columns. Feb 20, 2021 · I use a QTableWidget, not QTableView. row(), 3), Qt. indexAt(event. QtGui. i want to set the color of vertical header in CSS. pos()) menu = QMenu() #an action for everyone. int QTableWidget::rowCount () const. It all works perfectly. int column – PySide. Jan 18, 2017 · For the fonts you can try to do the next. I've managed to create a table, but want to add images in certain cells. item( Oct 12, 2021 · I have a QTableWidget with some rows. This function was introduced in Qt 4. The problem is that I want the push button column to be 15pt with at startup too. my_table. 2. I tried the code . setSpan(row, column, rowSpan, columnSpan) Parameters: row – PySide. stylesheet += "background-color:"+highlight+"}" table->setStyleSheet(stylesheet); The selection color does the one item that is selected while the item focus will color the rest of the items that should be highlighted. That is, your overviewTable->item(2,2) probably returns 0, thus causes a Segmentation fault in the setFont() call. So, when the user scrolls with the stand-alone scrollbar it triggers events on the 'real' hidden scroll bars. May 21, 2015 · There are a few ways to do this (full script is further down): Option 1: Set the background on the item, then add the item to the table. table. setHorizontalHeader(header) I end up with something that looks like this: This way a border does show up around the header. I found the solution with the help of the comment of @musicamante above. QHeaderView. You should set a class property (etc tableview's currentindex) which can be reset value from outside the class, by this, the delegate's default loop will compare the tableview's currentindex. PySide6. The coloring works, but all rows get colored, instead of the row that I specified. Oct 5, 2013 · You should check Qt Sylesheet Reference. I have set the selection behavior to select entire row. I'd also adapt your answer to actual python code, since the question uses Jul 10, 2020 · Problem is that when I remove Qtablwwidget section of code of style sheet then separating lines of rows disappears but row color works fine when import button is clicked. QTableWidgetItem('row1') Nov 11, 2019 · You can extract the data from each cell of the Table Widget by accessing it by iterating it through each row and column ( which can be done by ranging rowCount() each row & range of columnCount() per each column ) using the item() method. int . Aug 2, 2019 · In PyQt5, I am using the model view to display a table. setPalette(p) it does this: (I can't post images and I can post only two links!) I try to put the link in comment. rowHeight (row) ¶ Parameters: row – int. setStyleSheet("QTableWidget::item {border: 0px; padding: 5px;}") Now the cells have a padding of 5px. want to change the color where blue arrow is marked. setRowHeight(i, 100 ) delegate = ReadOnlyDelegate(self) self. Background role, I get some "tickbox" in my cell that I don't want. Note: The table takes ownership of the widget. If you don't like that specific height, just change it to something more acceptable (e. by clicking a "Clear Table" button), you can call the following function: self. Configure the QTableWidget to have a number of rows equivalent to the amount of items from the colors structure, and a number of columns with the members of one color entry, plus one. The model is the QAbstractTableModel, and I want to background color say row 0. ItemIsEnabled ) table. Code: May 16, 2013 · This is a python style code. The row and column specified is the cell that was pressed. The QTableWidgetItem class is a convenience class that replaces the QTableItem class in Qt 3. setFrameStyle(QFrame. horizontalHeaderItem(0). _data. Setting the margin to 0 did the trick: view. The previous number of rows is specified by oldCount, and the new number of rows is specified by newCount. And you can't just insert text string separated by tabs into table, you need to prepare it yourself, and then populate table with QTableWidgetItem's by calling QTableWidget. handled = False. when running with timeit on a df that is (1000,1000): In [5]: %timeit len(df. QTableWidget:edit-focus{ selection-background-color: red} and . This is my code: self. How to get both row and column number? Actually the row to which I am trying to set a background color also has some color set to it in table widget stylesheet. I can search data from the table, like, if I search for '10', whole data starting with '10' will be displayed. setFamily("Arial Black") afont. rigTable. you can also tried style sheet: Jun 20, 2016 · Then, I would like to read and store these values in a list. No model added. Sep 13, 2013 · Basically there are two ways: (1) I am not 100% sure why your code is not working, but my guess is the font you created is invalid and won't apply, usually you want to use the existing Font from the QHeaderView, manipulate it and reset it to ensure that all other settings are identical: Dec 16, 2019 · 1, QtWidgets. So I've tried : Jun 2, 2022 · File: untitled. I tried implementing QItemDelegate / QStyledItemDelegate but it doesn't work. For some reason, clicking on a cell is not sufficient to edit it, I need to double-click the cell to enter it. tableView = QTableView(self. tableView. Jun 13, 2014 · But it does not always work as expected. from PySide2 import QtCore, QtGui class PandasModel2(QtCore. verticalHeader. My Table. palette() p. ResizeToContents) # adapt the third column to fill all available space. Feb 27, 2018 · I'm trying to build a very simple application using pyqt5, I have a tableWidget with 5 rows the first row is hidden that has the ID from MySQL database. QWidget *QTableWidget:: cellWidget ( int row, int column) const. Oct 13, 2015 · self. I have a pyqt5 QTableWidget and i want to highight a specific cell of the table. Now I need to highlight the first row, since it shows the accurate search result. Thanks again. In this tutorial we'll learn how to use QTableView in PyQt, including how to model our data, format values for display, and add conditional formatting. However, Everything is working fine expect the QTableWidget Headers. Apr 4, 2010 · To apply @Narek's code to rows or columns, simply use a simple for loop and put a condition in to include the flags for rows/columns you do not want to be editable. There are 2 ways. Mar 25, 2013 · So you need to populate your QTableWidget with empty items first. I tried self. backgroundBrush = QBrush(QColor(255, 128, 128)) Gives the solution to my question but a new problem arises: the cell colour can't be May 7, 2020 · I'd suggest a small modification: using Qt::white won't always be a good thing, especially if the current style uses a different Base palette color, or if the item view's background uses a custom stylesheet or palette: Qt::transparent would probably be more consistent. Parameters: currentRow – int. Dec 19, 2017 · I'd like to have different selection color when an item is selected. cellEntered (row, column) # Parameters: row – int. Jan 19, 2017 · 0. I answer the question myself. But the QTableWidget::item:selected{ background-color: } only works when there is only one item selected, otherwise all selected items will have the same selection color. This element in the top-left part is not part of the QHeaderView but a QAbstractButton so a possible solution is to apply the stylesheet directly to the button: button = self. BackgroundRole: if QSqlQueryModel. stylesheet = "::section{Background-color:rgb(190,1,1);border-radius:14px;}" Table. Feb 10, 2019 · I currently have the python function (below) to build a QTableWidget from a pandas dataframe (df). @class MyDelegate : public QStyledItemDelegate { public: MyDelegate ( QObject *parent Jan 6, 2017 · For me, using PyQt4. red) table. Returns the widget displayed in the cell in the given row and column. And something strange is happening, if I add an ; affter the first } then the color is working and the border is not set, if I remove the ; then the color is not working and the border is set. If you want something for "mouse over" you may have to use "hover 1. int rowSpan – PySide. Use QStyledItemDelegate. Sets the span of the table element at (row , column ) to the number of rows and columns specified by (rowSpanCount , columnSpanCount ). For some reason though, the column with the checkbox doesn't get highlighted. height() + 6 ). 1) You can use delegates to draw the row background You will need to set the row to highlight in the delegate and based on that, do the highlighting. lista = [] listb = [] # i is always in range 4 in my code. 1. The header items are nothing more than QTableWidgetItems. tabSentimento) self. 2, QtWidgets. QTableWidget does not appear to have a setSizeHint() method. I am trying to change the default color for selection in a QTableWidget, but I need to make it transparent so that I can still see the color of the underlying cell. Now I want to make the 3rd row have a red border around it. Then the Proxy model filters out every third index. item(row, column) when the user clicks a button to add stock the program should then use the product code it will have just got to make the change to the database after getting the quantity added from the user. setCellWidget(row, 1,push) self. data(Qt. Apr 26, 2021 · 1. Return type: int. red)' in 'data' function upon can set the background-color of cells with value 'In error', but the background-color was already set when the Qtableview finish created, i just want to set cell's background color when i call function 'set_cell_color' ,that means i can control the cell's background even after Qtableview Mar 11, 2016 · Two part question: I have a 10x10 QTableWidget with QTableWidgetItem in each cell. QtCore. However, when I try to resize the rows, all of the rows are resized, except from the last one. [signal] void QTableWidget:: cellDoubleClicked (int row, int column) This signal is emitted whenever a cell in the table is double clicked. show () app = QtGui. The following code reads a csv file into a QTableWidget: May 8, 2017 · I'm having a QTableWidget with 9000 data. It's based on the size hint for the row, which is derived from the size hint for the item delegate (amongst other things). Jul 16, 2014 · 3. Sep 8, 2011 · How can I set the cell borders in a QTableWidget to 0px? Preferably I can choose which sides of a cell's border to set to 0, but I can live with setting them all to 0 as well. column – int. self. setObjectName("Dialog") Dialog Mar 9, 2016 · The cell background color seems to work with the above style, but now the border isn't showing anymore. . This can either be done via Qt Designer (in the QAbstractScrollArea section of the Property Editor), or programmatically, like this: self. setLineWidth(1) table. I want to make rows clickable and when clicked I need to check the hidden comlumn in order to retreive the information from mysql based on it's ID in order to modify or delete the row below is May 23, 2019 · 1. for i in range(4): # j is always the length of the unique values list of a field of a qgis layer, # selected by the user on a previous step. setColumnWidth(i, 250 ) self. QFont() afont. In your example, create the item before you attempt to set the background color. I am trying to change the background color of selected cell in a QTableWidget. Subclass QStyledItemDelegate. I would like to style this cellWidget based on whether or not the row is selected. Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers: QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1"). ItemIsEnabled)", you use it to set the cell property QtCore. setPalette(palette) # add layout and child widgets. These are the top rated real world Python examples of PyQt4. data(self, self. backgroundRole(), Qt. setAlternatingRowColors extracted from open source projects. setStyleSheet(stylesheet) That is if you want different horizontal and vertical headers. setSelectionBehavior(QAbstractItemView. exit (app. setItemDelegateForRow( 1, delegate) self. It clearly states that you try to color the header. We must obtain the data in the archive column (in my example it is the third one) and verify that it satisfies the condition (in this case true), if so we return the QBrush object with the desired color. red) widget. QAbstractTableModel): # Feb 1, 2018 · This topic has been deleted. setAlternatingRowColors - 16 examples found. QTableWidget - Change the row color. You’ll understand how the layout of the TableWidget works in this example. I want to change some background color of the tableWidget's cells. But, I don't know how to modify these cells. I used : self. It is the source model's data() that sets each of `QTableView's indexes background colors to a green if the index's row number is even and to a blue if it is odd. py from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog. Feb 10, 2020 · pyqt5 mvc QTableView modelview excel numpy pandas qt pyqt data-science python qt5 pyqt5-data-science. Dec 6, 2016 · All you need to do is set the size adjust policy on the table when initialising the UI, and it will automatically resize to fit the contents. Aug 27, 2018 · QTableView. QTableView. Jun 14, 2013 · 4. setRowCount(0) The code you've provided oddly works but isn't populating data into the table anymore. currentCellChanged(currentRow, currentColumn, previousRow, previousColumn) ¶. This signal is emitted whenever a cell in the table is pressed. 0. You have a couple of questions rolled into oneshort answer, yes, you can add a button to a QTableWidget - you can add any widget to the table widget by calling setCellWidget: # initialize a table somehow. Returns the height of the given row. column() == N: #treat the Nth column special row May 23, 2016 · Make sure to hide the horizontal scroll bars for each individual table and then adding a new scrollbar that connected the two hidden scroll bars. QTableWidget:focus{ selection-background-color: red} but none of them seem to turn anything red, it still seems to remain orange if focused and gray if not. So that the column width is the same width as the push button. Jul 24, 2018 · I am new in pyqt4 and I can't figure out how to do this. . PySide2. I have a QtableWidget with data in it. if role == Qt. So your means to setting font is completely right. setFont(afont) If you want to see more families, you can always look at the available ones from QtDesigner. Jul 9, 2012 · QTableWidget{ selection-background-color: red} I also tried . Jul 19, 2020 · for i in range( 5 ): self. initStyleOption(option, index) if not index. setColor(table. row_number, column_number, QTableWidgetItem(str(data))) If you want to clear the table (e. python. for j in range(un_values_len): Jun 14, 2012 · QTableWidget (which inherits QTableView) has a method horizontalHeaderItem(int) which can be used to get the header items, so you maybe could swich to use that instead of QTableView? Share Improve this answer In the sample code below (heavily influenced from here), I want the entire row of the clicked cell to be selected instead of the individual cell. every = QAction("I'm for everyone", menu, triggered = FOO) if index. arg( pow(row, column+1))); tableWidget->setItem(row, column, newItem); Each item can have its own Jun 18, 2020 · I am new to pyqt. Mar 29, 2021 · If you want all cells to have that background color then you can use a delegate: def initStyleOption(self, option, index): super(). exec_ ()) main () I know how to set the Horizontal Headers background color, but how can i set the Headers Background Color for a specified Row? In this example, say i want to May 22, 2017 · 5. horizontalHeader(). tableWidget->setItem(8, 0, new QTableWidgetItem); tableWidget->item(8, 0)->setBackground(Qt::red); Please also note that you should use setBackground instead of setBackgroundColor as the latter is Mar 20, 2020 · Use 'return QBrush(Qt. This signal is emitted whenever a cell in the table is double clicked. values) 6. The issue is that when I select a row, the background color of the complete row becomes the standard orange and the text color becomes white. Yes it is possible but only with a slight trick. So is there a way to make every item have individual selection color? Aug 4, 2019 · I have a table widget. Otherwise, this should do the job. 4 and PyQt5. So i think this is a good method to always scroll to the bottom of tablewidget : Feb 25, 2019 · The delegate by default uses the BackgroundRole information if it is available so the solution is just to return a QColor, QBrush or similar. self. setItem. ItemIsSelectable | Qt. index = self. However most of the times the background will be ignored because the actual QStyle will override it. 2) Catch the signal of current row. If I extract the header and set the style, shadow, and line width properties of its underlying frame via: header = table. index). Oct 15, 2020 · change PyQt5 QTableWidget row stylesheet when a condition is met. btn = QPushButton(table) Jul 17, 2015 · if anyone is experiencing slowness or sluggishness when using the PandasModel, the issue for me was how rowCount is calculated. of 7 runs, 100000 loops each) In [7]: %timeit Sep 10, 2015 · table = self. I would like this QTableWidget to default to a size that shows all cells. It provides an item for use with the QTableWidget class. Python QTableWidget. I'm trying to make a border for rows in QTableWidget with different ways, but all solutions don't respond my requirements. QTableWidget. However, setting setAlternatingRowColors(true) only alternates row colors that has data - the rest of the table is just white, which is not the behaviour you'd expect (look in the bookmark list of any browser, for example - empty rows has alternating colors). g. If not using delegates and one doesn't want to set alignment for every QTableWidgetItem created anew, then you could set the prototype item in the table widget like so. In this example, we are setting item1 to have "row1" as the content. Apr 4, 2014 at 22:50. Qt. setAutoFillBackground(True) palette = widget. setFlags(QtCore. def createTable(self): # Create table. I'm having issues using tables in my GUI that I'm creating with Qt Designer, specifically the setItem() and item() functions I wrote two functions each to be executed by a push button. Is it possible to change color when clicked/selected and return to default color when not selected. Jul 26, 2012 · The 1st row is selected by the user and is highlighted, a process in the background updates the values in the table and updates the value in the 3rd row to 4. You can rate examples to help us improve the quality of examples. backgroundRole(), QtCore. QWidget(tabwidget) widget. I'm not sure if this is very robust, but at least it is working fine on Windows. – OnWhenReady. 18 µs ± 5. statTable. setAutoFillBackground(True) p = table. This works for the selected cells like having a selected row. By executing a function, Python put in cells list's elements that I've created before. I don't want to use setMaximumHeight because the number of rows may vary. The "standard" row height is what you get when you don't resize to contents. By default, for a table constructed without row and column counts, this property contains a value of 0. There are no events based on QTableWidgetItem, but you can do this: reimplement the mouseMoveEvent() of QTableWidget, you can get the mouse position; use itemAt() method to get the item under your mouse cursor; customize your item; This may simalute what you want. from PyQt5 import QtCore as qtc. values returns a numpy array, which is a magnitude slower than len(df. Returns the number of rows. Nov 15, 2022 · PyQt6 QTableWidgetItem Change Background Color if Value Changes. Plain) header. Returns the item for the given row and column if one has been set; otherwise returns nullptr. Only users with topic management privileges can see it. You can disable editing by setting the flags ItemIsSelectable and ItemIsEnabled for each item in your table: table = QTableWidget(10,10) for i in range(10): for j in range(10): item = QTableWidgetItem(str(i*j)) item. Hope, It will usefull to you guys. Put the number in to get the result: 0:left 1:left 2:right 3:right 4:centre. I've read that I need to subclass the QTableWidget class, or possibly the QTableWidgetItem class and re-implement the QPaintEvent. In each row, one of the cells has another widget set via setCellWidget. BackgroundRole): option. tableWidget = QTableWidget() In this example we’ll be creating a PyQt QTableWidget filled with values as well. Also the property cellClicked is returning only row number. setItem(i, j, item) answered Sep 22, 2015 at 21:59. Apr 4, 2014 at 22:57. answered Apr 26, 2021 at 22:42. import sys. setStyleSheet("background-color: lightblue") To avoid the use of findChild it can be set via QTableWidget: stylesheet Nov 29, 2017 · 1. horizontalHeader() header. setStyleSheet("QTableView{ selection-background-color: rgba(255, 0, 0, 50); }") self. Setting the style of the vertical header Dec 13, 2013 · 2. I was not successful into adding header Jun 10, 2020 · I have a QTableView with three columns The second column is about numbers, there are only three types: 1, -1 and 0. setGeometry(QRect(550,10,510,700)) This property holds the number of columns in the table. findChild(QAbstractButton) button. Unfortunately, the default Size Hint used by QSizePolicy. DisplayRole): I have a QTableView containing data rows from a database. resizeSection(section, 30) This is the result I get. How can i do it? self. column – int Jul 29, 2015 · This model changes the foreground & background colors of some cells based on the displayed values. In the previous tutorial we covered an introduction to the Model View architecture. setCentralWidget(table) This produces the following window. The two problems are: Jun 4, 2014 · To insert a row, you have to follow something similar to this: tableWidget = QTableWidget() currentRowCount = tableWidget. horizontalHeader. QtWidgets. I am using Python 3. You have to do something like. setItemDelegateForColumn( 0, delegate) In this PyQt5 Tutorial, we are going to learn how we can use QStyledItemDelegate class to set rows or columns Read-Only on a QTableWidget. If this foreground color is not the default WindowText color of the palette, that means a specific color is set and this specific color is used for the highlighted text color. If you like to color the background of the headerView: tableWidget->verticalHeader ()->setStyleSheet ("QHeaderView::section { background-color:blue }"); – OnWhenReady. setCellWidget ( 0, 1, QLabel ( "B" )) self. All that I want, is to draw a rectangle around a whole row. item1 = QtGui. EDIT: Either setting the border to 0px or setting the color to white would be good as well. I just work with QTableWidgetItem. Feb 22, 2018 · self. I will check there. 13 on Windows, setting a background-color on the QTableWidget QTableCornerButton element in the Qt stylesheet has an effect but setting background-image has not. For reference, the cellWidget is another QTableWidget but it is disabled/not editable and essentially read-only. tableWidget. QTableWidgetItem *QTableWidget::item (int row, int column) const. Jan 28, 2022 · Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand Aug 20, 2012 · 34. With setVerticalHeaderItem of QTableWidget you can set a QTableWidgetItem even for header rows and there you can define a background brush for each row. but when I keep that section of code in the style sheet then if I click on import button it does not reflect although line of rows borders show perfectly fine. ItemIsEnabled to disabled, so you can't select or edit the cell Apr 5, 2011 · I'm very new to Python and even newer to PyQt. what i want to achieve now is to colorize each order This slot is called whenever rows are added or deleted. Anyway, it just set the color of grid to red. You can also set a QTableWidget to only allow the selection of rows. afont = PyQt4. Stretch) Note that if you remove a column and insert another one in the same place, you'll need to set its section size or mode once again. currentRow column = self. 'addRow(self)' to create and populate a row on QTableWidget with values from QLineEdit. table. setTextAlignment takes an int for the argument (alignment). cellDoubleClicked (row, column) # Parameters: row – int. Also tablewidget items also have a background color. Also, when I change to Qt. palette() palette. I want to have different colors for this three "types" of numbers (1,-1,0), coloring their rows with different colors. argv) ex = Example () sys. I am using python 3. tableWidget. Jun 10, 2021 · 2. Oct 13, 2015 · I know how to set the Horizontal Headers background color, but how can i set the Headers Background Color for a specified Row? In this example, say i want to have the Header Row with the Label "3" to be red? The above screenshots code: Jan 29, 2013 · row = self. dlg. Jan 8, 2012 · When you want to populate QTableWidget, you need to set row and column counts before inserting data example in documentation (PySide documentation is better than PyQt). table = QTableWidget(parent) table. int columnSpan – PySide. The row and column specified is the cell that was double clicked. Oct 21, 2014 · wrote on last edited by. currentColumn self. However, you can make the background-color transparent ( rgba(0,0,0,0) ) and then you see the background image of the widget shining through. Jan 19, 2021 · In PyQt I am trying to create a QTableWidget. setSizeAdjustPolicy(. It takes three main arguments, the row index, the column index, and a QTableWidgetItem object. setColor(widget. setColumnCount(1) # create an cell widget. Iterate over the items in that row and set background for each item. SelectRows) So now the selection color 2. Hi, We have a requirement where we want to change the border color of the QTableWidget item to pink when that item is clicked or selected. So the resulted colors are all unordered. The solution is the line "item. in the picture below, i have a QTableWidget to view data from one to many relation sqlite database, i managed to merge some columns output to display data correctly using setspan feature and help of this answer by @eyllanesc. For example I give row 2 and column 2, and I want that cell to be highlighted to edit,i mean for the element in blue. After creating a custom QLabel class that opens a QInputDiaglog popup when double clicked to change the value displayed in the cell, I realized that a QTableWidgetItem can be double clicked to edit its value. This way users can only have a single scrollbar to interact with. insertRow(currentRowCount, 0, QTableWidgetItem("Some text")) To clarify the last line of code, the first parameter of insertRow() is the current row Feb 6, 2022 · Solved! Two ways to changed QTableView Row background color when user mouse clicking. index(item. For example, I want to get the current data of a cell at (x,y) and add an integer. Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers: pow(row, column+1))); tableWidget->setItem(row, column, newItem Jun 25, 2019 · I also have my table setup so that the entire row is highlighted when a single column is selected. setPointSize(11) atable. QApplication (sys. Maximum cuts off some of the rows and columns in the table. setRowCount(1) table. Nov 26, 2009 · This delegate will check the foreground color role of the item. I had try QStyledItemDelegate class, but that is not my way, because delegates are used only for item[ row, column ], not for the whole rows or columns. If you just want to colour the background of the tab body, then set the background role of its top-level content widget: widget = QtGui. 21 ns per loop (mean ± std. from PyQt5 import QtWidgets as qtw. Jul 8, 2014 · In my code, I've created a QTableWidget with 50 columns and 2 rows. I'm using: ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); for highlighting the selected row. setSectionResizeMode(. I messed around with stylesheets for the check box (with selection-background-color) but it still doesn't do anything. What properties do I have to set to make the selected row May 20, 2010 · As the Qt document says, QTableWidgetItem * QTableWidget::item (int row, int column) const. If this is an even row, we then set the background to a light red/pink. Box | QFrame. Nov 10, 2021 · push = QPushButton("T") push. I'd like to have my table resize in order to adjust its size to the data, or at least to be able to set the column sizes as (say) 70/15/15 % of the available space. setItem(. I am new to python and Qt. QHeaderView::section{background-color:rgb(120,120,120);color: white;} but i get this Please check your question. kw qh uh hu hp cj mc up bn mu