qtablewidget

QTableWidgetItem shrinking

随声附和 提交于 2019-12-12 04:23:18
问题 I have an issue usign QTableWidgetItem. I normally use the QTableWidget like this this->setItem(i, j, new QTableWidgetItem()); this->item(i, j)->setText(string); The column I'm writing to is narrow, only about 20px. I need to write 2 digits in there and from the definition I cannot resize the column. The problem is that once the text overlaps the column width, it totally disappears and only three dots (or even nothing) appear instead. Can I suppress this behavior? I dont mind if there will be

Change QTableWidget default selection color, and make it semi transparent

≡放荡痞女 提交于 2019-12-12 03:33:44
问题 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. I used : self.setStyleSheet("QTableView{ selection-background-color: rgba(255, 0, 0, 50); }") self.setSelectionBehavior(QAbstractItemView.SelectRows) So now the selection color is kind of red, but some cells are defined as: cell.setBackgroundColor(color) ... self.setItem(i, j, cell) And still the color of the cell is overwritten

Qt QCombobox currentIndexChanged signal

人走茶凉 提交于 2019-12-12 02:09:54
问题 How get ItemIndex from one ComboBox and send to another ComboBox? Both Comb's created in QTableWidget QComboBox *comboA = static_cast<QComboBox*>(ui->tableWidget->cellWidget(0,0)); QComboBox *comboB = static_cast<QComboBox*>(ui->tableWidget->cellWidget(0,1)); QObject::connect(comboA, SIGNAL(currentIndexChanged(int)),comboB, SLOT(setCurrentIndex(int))); But this code does not work. Rather, it is necessary to define new methods for pointers. 来源: https://stackoverflow.com/questions/17748109/qt

Change QHeaderView data

可紊 提交于 2019-12-11 20:44:33
问题 I try to modify the text of my QHeaderView (Horizontal) in my QTableWidget. First question: Is it possible to set it editable like a QTableWidgetItem ? Second question: If it's not possible, how can I do that, I tried to repaint it like this: void EditableHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const { painter->save(); QHeaderView::paintSection(painter, rect, logicalIndex); painter->restore(); painter->setPen(Qt::SolidLine); painter->drawText(rect, Qt:

Highlight search results in qtablewidget(select and highlight that text or character not all of the row or column)

时光毁灭记忆、已成空白 提交于 2019-12-11 16:39:32
问题 I use method1 to find some text in qtablewidget rows. method1 : def FindItem(self): items = self.SuraBRS.findItems( self.SearchTbox.text(), QtCore.Qt.MatchContains) if items: results = '\n'.join( 'row %d column %d' % (item.row() + 1, item.column() + 1) for item in items) else: results = 'Found Nothing' print(results) Now I want to know how to highlight results or change their color. I want to select and highlight that text or character not all of the row or column . 回答1: To be able to change

Updating a Qtablewidget from contextmenu linedit-pyqt

对着背影说爱祢 提交于 2019-12-11 14:37:12
问题 I have a QTableWidget with which I would like to update from a QLinEdit embedded into a context menu. Now, in the QLinEdit a server name is entered, when the key is pressed the program scans MySQL database to see if the server name is in it, if it is, it updates the QTableWidget with the data from the server name table, if it is not found, it gives an error messageBox . What I can not do is connect the context menu QLinEdit to update the QTableWidget . connecting QTableWidget to context menu:

Python PyQt QTableWidet: How to implement an “advanced search” function

早过忘川 提交于 2019-12-11 14:32:57
问题 Say there's a QTableWidget filled with a user's data, and he/she wants to be able to perform an "advanced search" on it using multiple user-defined conditional statements: how would one (the programmer, not the user) go about implementing a function in the code that enables the user to perform this search? For example, let's say the user wants results of the following search: (column1 > 20 AND column2 < 50) OR column3 = "cloud" The first approach that comes to mind would be to somehow take

How to work with signals from QTableWidget cell with cellWidget set

帅比萌擦擦* 提交于 2019-12-11 12:42:50
问题 I've got a QTableWidget with some columns inside. Due to my needs I set QComboBox inside some columns and fill them with necessary data. void settingsDialog::onAddFieldButtonClicked() { fieldsTable->setRowCount(++rowCount); combo = new QComboBox(); combo->addItem(QString("Choose from list...")); foreach( int height, heightsAvailable) combo->addItem(QString("%1").arg(height)); fieldsTable->setCellWidget(rowCount-1, 3, combo); // etc for other columns ... } The quetsion is how to catch signals

Accessing QTableWidget's data from another class

穿精又带淫゛_ 提交于 2019-12-11 10:52:02
问题 I've got a child widget (it's a configuration dialog to my MainWindow ) with a QTableWidget on it. panelSettingsDialog.h: public: explicit PanelSettingsDialog(QWidget *parent = 0); ~PanelSettingsDialog(); public: QTableWidget *tableWidget; private: PanelSettingsDialog *panelSettingsDialog; panelSettingsDialog.cpp: #include "panelsettingsdialog.h" #include "ui_panelsettingsdialog.h" #include <QCheckBox> PanelSettingsDialog::PanelSettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui:

How can I print data from my database while in QTableWidget?

好久不见. 提交于 2019-12-11 07:15:07
问题 How can I print my data from my database (sqlite) into a notepad /word document from my table in my GUI (using the same formatting). Here is my code for the table which is represented on my gui. class Table(QtGui.QDialog): def __init__(self): super(Table, self).__init__() with sqlite3.connect('database.db') as db: cursor=db.cursor() cursor.execute('select* from Receipt Order BY ReceiptID ASC') title = [cn[0] for cn in cursor.description] rows = [cn[0] for cn in cursor.description] cur=cursor