qtablewidget

How to word wrap text in the rows and columns of a QTableWidget?

你说的曾经没有我的故事 提交于 2019-12-07 05:05:03
问题 I tried: QTableWidget *j = new QTableWidget (10000, 5, centralWidget); j->setColumnWidth (0, 500); j->setColumnWidth (1, 30); j->setColumnWidth (2, 30); j->setColumnWidth (3, 320); j->setColumnWidth (4, 310); j->setWordWrap (true); Also tried resizeColumnsToContents and resizeRowsToContents , but failed. If the text is longer than the set width, I want the sentence to break down. Currenty, the lengthy part of the sentence just doesn't get shown. 回答1: setWordWrap defines the behaviour of the

how to make a cell in a QTableWidget read only?

耗尽温柔 提交于 2019-12-07 01:40:41
问题 i have the following code defining the gui of my app class Ui (object): def setupUi(): self.tableName = QtGui.QTableWidget(self.layoutWidget_20) self.tableName.setObjectName(_fromUtf8("twHistoricoDisciplinas")) self.tableName.setColumnCount(4) self.tableName.setRowCount(3) and the following code in my app class MainWindow(QtGui.QMainWindow): def __init__(self): self.ui = Ui() self.ui.setupUi(self) self.createtable() #creating a tw cell def cell(self,var=""): item = QtGui.QTableWidgetItem()

Adding horizontal slider to QTableWidget

为君一笑 提交于 2019-12-06 19:55:29
I am trying to design something like a timeline view for my video player. I decided to use QTableWidget as the timeline since it suits my purpose. My widget looks like this: I want the green line to run through the widget when i click on play. Here is my MVCE example: //View.cpp View::View(QWidget* parent) : QGraphicsView(parent) { QGraphicsScene* scene = new QGraphicsScene(this); TableWidget* wgt = new TableWidget; scene->addWidget(wgt); QGraphicsLineItem* item = new QGraphicsLineItem(30, 12, 30, wgt->height() - 9); item->setPen(QPen(QBrush(Qt::green), 3)); item->setFlags(QGraphicsItem:

How to import a CSV file to a QTableWidget

和自甴很熟 提交于 2019-12-06 12:28:43
问题 I am student programmer and I am using Qt to develop a GUI interface for work and Im having trouble figuring out how I should make this this import function work. A bit of programmers writers block if you will. SO far I have this for code: void InjectionLocationsDialogExpanded::importCSVFile() { QString fileName = QFileDialog::getOpenFileName(this, ("Open File"), "/home", ("csv File(*.csv)")); QString data; QFile importedCSV(fileName); QStringList rowOfData; QStringList rowData; int tempint =

Qt: Different tableWidget member names on workstations

点点圈 提交于 2019-12-06 11:36:33
I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens. I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line: ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); This works just fine. I have a few of this codelines. However, when I now copy over my source code to the other PC to work on it, I get the following compile error:

Disable user to click over QTableWidget

不打扰是莪最后的温柔 提交于 2019-12-06 06:34:05
I have QTableWidget with CheckBoxes in some cells. I want to disable user to perform mouse click over the table cells (so he can't change checkBox state) for some time while I am using data from the table. I've tried table.setDisabled(1) but that disables whole table and I need scroll to be enabled. Any help would be appreciated. EDIT To be more precise: there could be up to 15x3000 cells in table, filled with text(editable), checkbox(checkable), svg graphic(opens other window when double click on it) or some custom widgets(which also have clickable or editable parts). I need to disable user

add custom widget to QTableWidget cell

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:53:13
问题 I have custom widget made with qt designer and i want to add it to QTableWidget cell. But it doesn't work. Here is the code : int nRows =10; for(int row = 0; row < nRows;row++;) { QTableWidgetItem* item = new QTableWidgetItem(); CustomWdg* wdg=new CustomWdg( ); mTableWdg->insertRow( row ); mTableWdg->setItem(row, 0, item); mTableWdg->setCellWidget( row, 0, wdg ); } 回答1: If you want to add custom widget into table cell you can use QItemDelegate. Create your own Delegate class and inherit it

Widget alignment in cell pyqt

坚强是说给别人听的谎言 提交于 2019-12-05 20:34:27
I'm developing some tool in PyQT4 and Python 2.7 and I stuck in a little problem. I've 3 buttons in stored in widget and that widget is in cell in the table (QTableWidget). So my problem is that I can't align widget to top of cell and tool doesn't resize row height to defined in widget minimum/fixed height. Here is how it looks now with method resizeRowToContents. And I want something like this I did something similar with fixed row height but its not the way I want. I solved this problem in quite simply way. First of all I changed margin of layout to 0px (later I changed that to 3px to have

How to word wrap text in the rows and columns of a QTableWidget?

风流意气都作罢 提交于 2019-12-05 10:11:29
I tried: QTableWidget *j = new QTableWidget (10000, 5, centralWidget); j->setColumnWidth (0, 500); j->setColumnWidth (1, 30); j->setColumnWidth (2, 30); j->setColumnWidth (3, 320); j->setColumnWidth (4, 310); j->setWordWrap (true); Also tried resizeColumnsToContents and resizeRowsToContents , but failed. If the text is longer than the set width, I want the sentence to break down. Currenty, the lengthy part of the sentence just doesn't get shown. setWordWrap defines the behaviour of the text, without altering column size. If you need to keep column width fixed, call resizeRowsToContents after

How to limit the selection in a QTableWidget

╄→гoц情女王★ 提交于 2019-12-05 08:27:09
How would I go about limiting the rows/columns selected in a QTableWidget? I need to force the user to use a contiguous selection (already done) to select exactly two columns and any amount of rows. Thanks! You will probably have to do one of 2 things: You would have to subclass QItemSelectionModel and implement functions for adding and deleting selected QModelIndex es so that you only add items from 2 rows to it. You can do this by having a custom implementation for catching signals that QItemSelectionModel emits such as: connect(tableWidget->selectionModel(), SIGNAL(selectionChanged