model-view

Pyqt4 Model View - Adding Slider , CheckBox Line Edit in Table model

Deadly 提交于 2019-12-02 13:06:23
I am working on a ui as shown in the image below. In the First columns i have a Check Box, Second columns i have a Slider, Third just text the slider value applied to a function. the result will be shown in the third column. I am not not able to see the slider not the checkbox Output is shown in the image Code: from PyQt4 import QtGui, QtCore, uic import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class PaletteTableModel(QtCore.QAbstractTableModel): def __init__(self, colors = [[]], parent = None): QtCore.QAbstractTableModel.__init__(self, parent) self.__colors = colors def

A checkbox only column in QTableView

淺唱寂寞╮ 提交于 2019-12-01 09:19:04
I have a table in Sqlite database which I display using QTableview and QSqlQueryModel. The first column needs to have a header which is a checkbox and all the items in the column need to be checkboxes too. I have implemented the first column header as a checkbox and it works perfectly. Since the checkboxes in the column need to be centered, I used a delegate to paint it. I have painted checkboxes using the following code, but they cannot be checked or unchecked. I do not know how to implement that. static QRect CheckBoxRect(const QStyleOptionViewItem &view_item_style_options) {

A checkbox only column in QTableView

情到浓时终转凉″ 提交于 2019-12-01 06:23:49
问题 I have a table in Sqlite database which I display using QTableview and QSqlQueryModel. The first column needs to have a header which is a checkbox and all the items in the column need to be checkboxes too. I have implemented the first column header as a checkbox and it works perfectly. Since the checkboxes in the column need to be centered, I used a delegate to paint it. I have painted checkboxes using the following code, but they cannot be checked or unchecked. I do not know how to implement

How to refresh a QSqlTableModel while preserving the selection?

余生长醉 提交于 2019-11-28 08:31:31
I am using a QSqlTableModel and QTableView to view an SQLite database table. I would like to have the table auto refresh every second or so (it's not going to be a very large table - a couple of hundred rows). And i can do this - like so: QTimer *updateInterval = new QTimer(this); updateInterval->setInterval(1000); updateInterval->start(); connect(updateInterval, SIGNAL(timeout()),this, SLOT(update_table())); ... void MainWindow::update_table() { model->select(); //QSqlTableModel* sqlTable->reset(); //QTableView* } But this removes any selection I have, so the selections only last for up to a

How to refresh a QSqlTableModel while preserving the selection?

我是研究僧i 提交于 2019-11-27 02:23:34
问题 I am using a QSqlTableModel and QTableView to view an SQLite database table. I would like to have the table auto refresh every second or so (it's not going to be a very large table - a couple of hundred rows). And i can do this - like so: QTimer *updateInterval = new QTimer(this); updateInterval->setInterval(1000); updateInterval->start(); connect(updateInterval, SIGNAL(timeout()),this, SLOT(update_table())); ... void MainWindow::update_table() { model->select(); //QSqlTableModel* sqlTable-