Уведомления

Группа в Telegram: @pythonsu
  • Начало
  • » GUI
  • » QTableView делегат блокирует таблицу для редактирования [RSS Feed]

#1 Март 15, 2011 21:22:17

g-kit
От:
Зарегистрирован: 2009-11-16
Сообщения: 41
Репутация: +  0  -
Профиль   Отправить e-mail  

QTableView делегат блокирует таблицу для редактирования

привет,

есть QTableView таблица - работает ок. При добавлении делегата - комбобокс, остальные ячейки становлятся нередактируемыми. Все перепроверил - немогу найти баг… что я делаю не так? Код:


class MainForm (QtGui.QMainWindow):

self.srcTableModel = srcTableModel(self.ui.srcTable)
self.ui.srcTable.setModel(self.srcTableModel)
self.ui.srcTable.setItemDelegate(srcShipDelegate(self))




class srcShip(object):

def __init__(self, equipment, srcCode, srcName, srcX1, srcY1, srcType, zoneSize, srcHeight, srcDiameter, gasDepletion, gasTemperature):
self.equipment = QtCore.QString(equipment)
self.srcCode = srcCode
self.srcName = QtCore.QString(srcName)
self.srcX1 = srcX1
self.srcY1 = srcY1
self.srcType = QtCore.QString(srcType)
self.zoneSize = zoneSize
self.srcHeight = srcHeight
self.srcDiameter = srcDiameter
self.gasDepletion = gasDepletion
self.gasTemperature = gasTemperature



class srcTableModel(QtCore.QAbstractTableModel):

def __init__(self, fileName = QtCore.QString()):
super (srcTableModel, self).__init__()
self.ships =
self.fileName = fileName
self.dirty = True


def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)



def columnCount (self, index=QtCore.QModelIndex()):
return 11


def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == EQUIPMENT:
return (QtGui.QApplication.translate(“MainWindow”, “Виробництво”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCCODE:
return (QtGui.QApplication.translate(“MainWindow”, “№ дж.”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCNAME:
return (QtGui.QApplication.translate(“MainWindow”, “Найменув. дж.”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCX1:
return (QtGui.QApplication.translate(“MainWindow”, “X,м”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCY1:
return (QtGui.QApplication.translate(“MainWindow”, “Y,м”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCTYPE:
return (QtGui.QApplication.translate(“MainWindow”, “Тип дж.”, None, QtGui.QApplication.UnicodeUTF8))
elif section == ZONESIZE:
return (QtGui.QApplication.translate(“MainWindow”, “Розмір СЗЗ”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCHEIGHT:
return (QtGui.QApplication.translate(“MainWindow”, “Висота дж., м”, None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCDIAMETER:
return (QtGui.QApplication.translate(“MainWindow”, “Діаметер дж., м”, None, QtGui.QApplication.UnicodeUTF8))
elif section == GASDEPLETION:
return (QtGui.QApplication.translate(“MainWindow”, “Витрата ПГВС, м3/с”, None, QtGui.QApplication.UnicodeUTF8))
elif section == GASTEMPERATURE:
return (QtGui.QApplication.translate(“MainWindow”, “Темпер. ПГВС”, None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)


def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships
column = index.column()
if role == QtCore.Qt.DisplayRole:
if column == EQUIPMENT:
return QtCore.QVariant(ship.equipment)
elif column == SRCCODE:
return QtCore.QVariant(ship.srcCode)
elif column == SRCNAME:
return QtCore.QVariant(ship.srcName)
elif column == SRCX1:
return QtCore.QVariant(ship.srcX1)
elif column == SRCY1:
return QtCore.QVariant(ship.srcY1)
elif column == SRCTYPE:
return QtCore.QVariant(ship.srcType)
elif column == ZONESIZE:
return QtCore.QVariant(ship.zoneSize)
elif column == SRCHEIGHT:
return QtCore.QVariant(ship.srcHeight)
elif column == SRCDIAMETER:
return QtCore.QVariant(ship.srcDiameter)
elif column == GASDEPLETION:
return QtCore.QVariant(ship.gasDepletion)
elif column == GASTEMPERATURE:
return QtCore.QVariant(ship.gasTemperature)
return


def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)


def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships
column = index.column()
if column == EQUIPMENT:
ship.equipment = value.toString()
elif column == SRCCODE:
value, ok = value.toInt()
if ok:
ship.srcCode = value
elif column == SRCNAME:
ship.srcName = value.toString()
elif column == SRCX1:
value, ok = value.toInt()
if ok:
ship.srcX1 = value
elif column == SRCY1:
value, ok = value.toInt()
if ok:
ship.srcY1 = value
elif column == SRCTYPE:
ship.srcType = value.toString()
elif column == ZONESIZE:
value, ok = value.toInt()
if ok:
ship.zoneSize = value
elif column == SRCHEIGHT:
value, ok = value.toInt()
if ok:
ship.srcHeight = value
elif column == SRCDIAMETER:
value, ok = value.toInt()
if ok:
ship.srcDiameter = value
elif column == GASDEPLETION:
value, ok = value.toInt()
if ok:
ship.gasDepletion = value
elif column == GASTEMPERATURE:
value, ok = value.toInt()
if ok:
ship.gasTemperature = value
self.dirty = True
self.emit(QtCore.SIGNAL(“dataChanged(QModelIndex, QModelIndex)”), index, index)
return True
return False


def insertRows (self, position, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, srcShip(“Unknown”, position + 1, “Unknown”, 0, 0, “Unknown”, 0, 0, 0, 0, 0))
self.endInsertRows()
self.dirty = True
return True


def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships + self.ships
self.endRemoveRows()
self.dirty = True
return True


class srcShipDelegate(QtGui.QItemDelegate):

def __init__(self, parent=None):
super(shipDelegate, self).__init__(parent)

def createEditor(self, parent, option, index):
if index.column() == SRCTYPE:
combobox = QtGui.QComboBox(parent)
combobox.insertItem(1, QtGui.QApplication.translate(“MainWindow”, “Неорган.”, None, QtGui.QApplication.UnicodeUTF8))
combobox.insertItem(2, QtGui.QApplication.translate(“MainWindow”, “Організ.”, None, QtGui.QApplication.UnicodeUTF8))
combobox.insertItem(3, QtGui.QApplication.translate(“MainWindow”, “Основне”, None, QtGui.QApplication.UnicodeUTF8))
combobox.setEditable(True)
return combobox
else:
QtGui.QItemDelegate.createEditor(self, parent, option, index)

def setEditorData(self, editor, index):
text = index.model().data(index, QtCore.Qt.DisplayRole).toString()
if index.column() == SRCTYPE:
i = editor.findText(text)
if i== -1:
i = 0
editor.setCurrentIndex(i)
else:
QtGui.QItemDelegate.setEditorData(self, editor, index)

def setModelData(self, editor, model, index):
if index.column() == SRCTYPE:
model.setData(index, QtCore.QVariant(editor.currentText()))
else:
QtGui.QItemDelegate.setModelData(self, editor, model, index)



Офлайн

#2 Март 15, 2011 23:11:41

Андрей Светлов
От:
Зарегистрирован: 2007-05-15
Сообщения: 3137
Репутация: +  14  -
Профиль   Адрес электронной почты  

QTableView делегат блокирует таблицу для редактирования

На первый взгляд все более или менее. srcTableModel.setData, конечно, неимоверно восхищает.
Второго взгляда не будет - код невозможно запустить.



Офлайн

#3 Март 16, 2011 07:33:52

g-kit
От:
Зарегистрирован: 2009-11-16
Сообщения: 41
Репутация: +  0  -
Профиль   Отправить e-mail  

QTableView делегат блокирует таблицу для редактирования

его невозможно запустить по той причине, что это избранные цитаты - весь файл достаточно большой…



Офлайн

#4 Март 16, 2011 07:49:12

g-kit
От:
Зарегистрирован: 2009-11-16
Сообщения: 41
Репутация: +  0  -
Профиль   Отправить e-mail  

QTableView делегат блокирует таблицу для редактирования

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import sys

# Set API version (new - 2)
import sip; sip.setapi("QVariant", 1); sip.setapi("QString", 1)

from PyQt4 import QtCore, QtGui
from ui_tria_004 import Ui_MainWindow
import SubstDataBase

MAGIC_NUMBER = 0x570C4
FILE_VERSION = 1


class MainForm (QtGui.QMainWindow):

def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.srcTableModel = srcTableModel(self.ui.srcTable)
self.ui.srcTable.setModel(self.srcTableModel)
self.ui.srcTable.setItemDelegate(srcShipDelegate(self))
self.frmTableModel = frmTableModel(self.ui.frmTable)
self.ui.frmTable.setModel(self.frmTableModel)
self.emsTableModel = emsTableModel(self.ui.emsTable)
self.ui.emsTable.setModel(self.emsTableModel)

self.setCentralWidget(self.ui.splitter)

self.connect(self.ui.actionOpen, QtCore.SIGNAL("activated()"), self.openFile)
self.connect(self.ui.actionSave, QtCore.SIGNAL("activated()"), self.accept)
self.connect(self.ui.actionAddSrc, QtCore.SIGNAL("activated()"), self.addSrcShip)
self.connect(self.ui.actionRemoveSrc, QtCore.SIGNAL("activated()"), self.removeSrcShip)
self.connect(self.ui.actionAddFrm, QtCore.SIGNAL("activated()"), self.addFrmShip)
self.connect(self.ui.actionRemoveFrm, QtCore.SIGNAL("activated()"), self.removeFrmShip)
self.connect(self.ui.actionAddEms, QtCore.SIGNAL("activated()"), self.addEmsShip)
self.connect(self.ui.actionRemoveEms, QtCore.SIGNAL("activated()"), self.removeEmsShip)
self.connect(self.ui.actionSubstDB, QtCore.SIGNAL("activated()"), self.substDataBase)

self.ui.srcTable.setSelectionMode(QtGui.QTableView.SingleSelection)
self.ui.srcTable.setSelectionBehavior(QtGui.QTableView.SelectRows)
self.ui.srcTable.setAlternatingRowColors(True)

# self.ui.frmTable.setColumnHidden(SRCFRMCODE, True)
self.ui.frmTable.setColumnWidth(0, 40)
self.ui.frmTable.setSelectionMode(QtGui.QTableView.SingleSelection)
self.ui.frmTable.setSelectionBehavior(QtGui.QTableView.SelectRows)
self.ui.frmTable.setAlternatingRowColors(True)

self.proxyFrmTable = QtGui.QSortFilterProxyModel()
self.proxyFrmTable.setSourceModel(self.frmTableModel)
self.ui.frmTable.setModel(self.proxyFrmTable)
self.proxyFrmTable.setDynamicSortFilter(True)
self.connect(self.ui.srcTable.selectionModel(), QtCore.SIGNAL("currentRowChanged(QModelIndex, QModelIndex)"), self.frmTableProxy)

# self.ui.emsTable.setColumnHidden(SRCEMSCODE, True)
# self.ui.emsTable.setColumnHidden(FRMEMSCODE, True)
self.ui.emsTable.setSelectionMode(QtGui.QTableView.SingleSelection)
self.ui.emsTable.setSelectionBehavior(QtGui.QTableView.SelectRows)
self.ui.emsTable.setAlternatingRowColors(True)

self.proxyEmsTable = QtGui.QSortFilterProxyModel()
self.proxyEmsTable.setSourceModel(self.emsTableModel)
self.ui.emsTable.setModel(self.proxyEmsTable)
self.proxyEmsTable.setDynamicSortFilter(True)
self.connect(self.ui.frmTable.selectionModel(), QtCore.SIGNAL("currentRowChanged(QModelIndex, QModelIndex)"), self.emsTableProxy)

def substDataBase(self):
self.widget = SubstDataBase.substDataBase()
self.widget.show()

def addSrcShip(self):
row = self.srcTableModel.rowCount()
self.srcTableModel.insertRows(row)
index = self.srcTableModel.index(row, 0)
frame = self.ui.srcTable
frame.setCurrentIndex(index)
frame.setFocus()

def removeSrcShip(self):
frame = self.ui.srcTable
index = frame.currentIndex()
if not index.isValid():
return
if QtGui.QMessageBox.question(self, "Ships-Remove", "Remove this item?", QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return
indexRow = index.row()
self.srcTableModel.removeRows(indexRow)
# reset srcCode after deleting
srcRowCount = self.srcTableModel.rowCount()
# for last row do nothing
if indexRow == srcRowCount:
return
# change srcCode from deleted row to last one
for row in range(indexRow, srcRowCount):
# get deleted srcCode number
srcCode = self.srcTableModel.data(self.srcTableModel.index(row, SRCCODE)).toInt()[0]
# set deleted and following srcCode new number (-1)
self.srcTableModel.setData((self.srcTableModel.index(row, SRCCODE)), QtCore.QVariant(srcCode - 1))

def addFrmShip(self):
indexSrc = self.ui.srcTable.currentIndex()
if indexSrc.isValid():
indexSrcRow = indexSrc.row()
indexSrcCode = self.ui.srcTable.model().index(indexSrcRow,1).data().toInt()[0]
row = self.frmTableModel.rowCount()
self.frmTableModel.insertRows(row, indexSrcCode)
index = self.frmTableModel.index(row,0)
proxyIndex = self.proxyFrmTable.mapFromSource(index)
self.ui.frmTable.setCurrentIndex(proxyIndex)
else:
QtGui.QMessageBox.warning(self, QtGui.QApplication.translate("MainWindow", "Помилка додавання", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("MainWindow", "Додайте джерело викиду спершу!", None, QtGui.QApplication.UnicodeUTF8))

def removeFrmShip(self):
index = self.ui.frmTable.currentIndex()
proxyIndex = self.proxyFrmTable.mapToSource(index)
if not index.isValid():
return
if QtGui.QMessageBox.question(self, "Ships-Remove", "Remove this item?", QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return
indexRow = proxyIndex.row()
# this data need us later to delete related ems rows
indexFrmCode = self.ui.frmTable.model().index(indexRow,1).data().toInt()[0]
self.frmTableModel.removeRows(indexRow)
### resetting srcCode after deleting
##frmRowCount = self.frmTableModel.rowCount()
### for last row do nothing
##if indexRow != frmRowCount:
### change srcCode from deleted row to last one
##for row in xrange(indexRow, frmRowCount):
### get deleted srcCode number
##frmCode = self.frmTableModel.data(self.frmTableModel.index(row, SRCCODE)).toInt()[0]
### set deleted and following srcCode new number (-1)
##self.frmTableModel.setData((self.frmTableModel.index(row, FRMCODE)), QtCore.QVariant(frmCode - 1))

#deleting rows in emsTable which connecting to this frm row
emsRowCount = self.emsTableModel.rowCount()
for emsRow in xrange(emsRowCount, 0, -1):
frmEmsCode = self.emsTableModel.data(self.emsTableModel.index(emsRow-1,FRMEMSCODE)).toInt()[0]
if indexFrmCode == frmEmsCode:
self.emsTableModel.removeRows(emsRow-1)

##indexFrmCode_1 = emsRow-1
### resetting frmCode after deleting following for it's frm row
##emsRowCount_1 = self.emsTableModel.rowCount()
### change srcCode from deleted row to last one
##for row in xrange(indexFrmCode_1, emsRowCount_1):
### get deleted srcCode number
##emsCode = self.emsTableModel.data(self.emsTableModel.index(row, FRMCODE)).toInt()[0]
### set deleted and following srcCode new number (-1)
##self.emsTableModel.setData((self.emsTableModel.index(row, FRMCODE)), QtCore.QVariant(emsCode - 1))

def addEmsShip(self):
indexSrc = self.ui.srcTable.currentIndex()
indexFrm = self.ui.frmTable.currentIndex()
if not indexSrc.isValid():
QtGui.QMessageBox.warning(self, QtGui.QApplication.translate("MainWindow", "Помилка додавання", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("MainWindow", "Додайте джерело викиду спершу!", None, QtGui.QApplication.UnicodeUTF8))
return
if not indexFrm.isValid():
QtGui.QMessageBox.warning(self, QtGui.QApplication.translate("MainWindow", "Помилка додавання", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("MainWindow", "Додайте джерело утворення спершу!", None, QtGui.QApplication.UnicodeUTF8))
return
indexSrcCode = self.ui.srcTable.model().index(indexSrc.row(),1).data().toInt()[0]#берешь данные из ячейки в строке
indexFrmCode = self.ui.frmTable.model().index(indexFrm.row(),1).data().toInt()[0]#берешь данные из ячейки в строке
row = self.emsTableModel.rowCount()
self.emsTableModel.insertRows(row, indexSrcCode, indexFrmCode)
index = self.emsTableModel.index(row, 0)
proxyIndex = self.proxyEmsTable.mapFromSource(index)
self.ui.emsTable.setCurrentIndex(proxyIndex)

def removeEmsShip(self):
index = self.ui.emsTable.currentIndex()
proxyIndex = self.proxyEmsTable.mapToSource(index)
if not index.isValid():
return
if QtGui.QMessageBox.question(self, "Ships-Remove", "Remove this item?", QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return
indexRow = proxyIndex.row()
self.emsTableModel.removeRows(indexRow)

def frmTableProxy(self):
srcIndex = self.ui.srcTable.currentIndex()
if srcIndex.isValid():
srcRowIndex = srcIndex.row()
indexSrcCode = self.ui.srcTable.model().index(srcRowIndex, 1).data().toString() #берешь данные из ячейки в строке
self.proxyFrmTable.setFilterKeyColumn(0)
self.proxyFrmTable.setFilterRegExp('^' + indexSrcCode + '$')
self.ui.frmTable.setCurrentIndex(self.proxyFrmTable.index(0,0))
else:
regExp = QtCore.QRegExp('-1', QtCore.Qt.CaseInsensitive)
self.filterFrmTable.setFilterRegExp(regExp)


def emsTableProxy(self):
frmIndex = self.ui.frmTable.currentIndex()
if frmIndex.isValid():
indexFrmRow = self.ui.frmTable.currentIndex().row()#строка таблицы
indexFrmCode = self.ui.frmTable.model().index(indexFrmRow,1).data().toString()#берешь данные из ячейки в строке
self.proxyEmsTable.setFilterKeyColumn(1)
self.proxyEmsTable.setFilterRegExp('^' + indexFrmCode + '$')
self.ui.emsTable.setCurrentIndex(self.proxyEmsTable.index(0,0))
else:
regExp = QtCore.QRegExp('-1', QtCore.Qt.CaseInsensitive)
self.proxyEmsTable.setFilterRegExp(regExp)

def accept(self):
if self.srcTableModel.dirty and \
QtGui.QMessageBox.question(self, "Ships - Save?", "Save unsaved changes?", QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes:
try:
self.saveFile()
except IOError, e:
QtGui.QMessageBox.warning(self, "Ships - Error", "Failed to save: %s" % e)


def openFile(self):
fileName = QtGui.QFileDialog.getOpenFileName(self, "Load Data", "", "Trianon Project (*.tri)")
if fileName.isEmpty():
raise IOError, "no fileName specified for loading at openFile module"
self.loadFile(fileName)
self.ui.srcTable.setCurrentIndex(self.srcTableModel.index(0,0))

def saveFile(self, fileName = QtCore.QString()):
exception = None
fh = None
self.fileName = fileName
try:
if self.fileName.isEmpty():
self.fileName = QtGui.QFileDialog.getSaveFileName(None, "Ships - Choose Save File", "", "Trianon project (*.tri)")
fh = QtCore.QFile(self.fileName)
if not fh.open(QtCore.QIODevice.WriteOnly):
raise IOError, unicode(fh.errorString())
stream = QtCore.QDataStream(fh)
stream.writeInt32(MAGIC_NUMBER)
stream.writeInt16(FILE_VERSION)
stream.setVersion(QtCore.QDataStream.Qt_4_5)
srcRowCount = self.srcTableModel.rowCount()
stream.writeInt32(srcRowCount)
frmRowCount = self.frmTableModel.rowCount()
stream.writeInt32(frmRowCount)
emsRowCount = self.emsTableModel.rowCount()
stream.writeInt32(emsRowCount)
for row in range(srcRowCount):
equipment = self.srcTableModel.data(self.srcTableModel.index(row, EQUIPMENT)).toString()
srcCode = self.srcTableModel.data(self.srcTableModel.index(row, SRCCODE)).toInt()[0]
srcName = self.srcTableModel.data(self.srcTableModel.index(row, SRCNAME)).toString()
srcX1 = self.srcTableModel.data(self.srcTableModel.index(row, SRCX1)).toInt()[0]
srcY1 = self.srcTableModel.data(self.srcTableModel.index(row, SRCY1)).toInt()[0]
srcType = self.srcTableModel.data(self.srcTableModel.index(row, SRCTYPE)).toString()
zoneSize = self.srcTableModel.data(self.srcTableModel.index(row, ZONESIZE)).toInt()[0]
srcHeight = self.srcTableModel.data(self.srcTableModel.index(row, SRCHEIGHT)).toInt()[0]
srcDiameter = self.srcTableModel.data(self.srcTableModel.index(row, SRCDIAMETER)).toInt()[0]
gasDepletion = self.srcTableModel.data(self.srcTableModel.index(row, GASDEPLETION)).toInt()[0]
gasTemperature = self.srcTableModel.data(self.srcTableModel.index(row, GASTEMPERATURE)).toInt()[0]
stream << QtCore.QString(equipment)
stream.writeInt32(srcCode)
stream << QtCore.QString(srcName)
stream.writeInt32(srcX1)
stream.writeInt32(srcY1)
stream << QtCore.QString(srcType)
stream.writeInt32(zoneSize)
stream.writeInt32(srcHeight)
stream.writeInt32(srcDiameter)
stream.writeInt32(gasDepletion)
stream.writeInt32(gasTemperature)

for row in range(frmRowCount):
srcFrmCode = self.frmTableModel.data(self.frmTableModel.index(row, SRCFRMCODE)).toInt()[0]
frmCode = self.frmTableModel.data(self.frmTableModel.index(row, FRMCODE)).toInt()[0]
formationSrcName = self.frmTableModel.data(self.frmTableModel.index(row, FORMATIONSRCNAME)).toString()
evolvingGasDepletion = self.frmTableModel.data(self.frmTableModel.index(row, EVOLVINGGASDEPLETION)).toInt()[0]
evolvingGasTemperature = self.frmTableModel.data(self.frmTableModel.index(row, EVOLVINGGASTEMPERATURE)).toInt()[0]
stream.writeInt32(srcFrmCode)
stream.writeInt32(frmCode)
stream << QtCore.QString(formationSrcName)
stream.writeInt32(evolvingGasDepletion)
stream.writeInt32(evolvingGasTemperature)

for row in range(emsRowCount):
srcEmsCode = self.emsTableModel.data(self.emsTableModel.index(row, SRCEMSCODE)).toInt()[0]
frmEmsCode = self.emsTableModel.data(self.emsTableModel.index(row, FRMEMSCODE)).toInt()[0]
pollutanTCode = self.emsTableModel.data(self.emsTableModel.index(row, POLLUTANTCODE)).toInt()[0]
pollutantTName = self.emsTableModel.data(self.emsTableModel.index(row, POLLUTANTNAME)).toString()
emissionType = self.emsTableModel.data(self.emsTableModel.index(row, EMISSIONTYPE)).toString()
emissionConc = self.emsTableModel.data(self.emsTableModel.index(row, EMISSIONCONC)).toInt()[0]
emissionValue = self.emsTableModel.data(self.emsTableModel.index(row, EMISSIONVALUE)).toInt()[0]
emissionVolume = self.emsTableModel.data(self.emsTableModel.index(row, EMISSIONVOLUME)).toInt()[0]
stream.writeInt32(srcEmsCode)
stream.writeInt32(frmEmsCode)
stream.writeInt32(pollutanTCode)
stream << QtCore.QString(pollutantTName)
stream << QtCore.QString(emissionType)
stream.writeInt32(emissionConc)
stream.writeInt32(emissionValue)
stream.writeInt32(emissionVolume)
self.dirty = False
except IOError, e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception

def loadFile(self, fileName):
exception = None
fh = None
self.fileName = QtCore.QString(fileName)
try:
if self.fileName.isEmpty():
raise IOError, "no fileName specified for loading"
fh = QtCore.QFile(self.fileName)
if not fh.open(QtCore.QIODevice.ReadOnly):
raise IOError, unicode(fh.errorString())
stream = QtCore.QDataStream(fh)
magic = stream.readInt32()
if magic != MAGIC_NUMBER:
raise IOError, "unrecognized file type"
fileVersion = stream.readInt16()
if fileVersion != FILE_VERSION:
raise IOError, "unrecognized file type version"
stream.setVersion(QtCore.QDataStream.Qt_4_5)
self.srcTableModel.ships = []
self.frmTableModel.ships = []
self.emsTableModel.ships = []
srcRowCount = stream.readInt32()
frmRowCount = stream.readInt32()
emsRowCount = stream.readInt32()

for row in range(srcRowCount):
if stream.atEnd():
raise IOError, "Stream loading error!"
equipment = QtCore.QString()
stream >> equipment
srcCode = stream.readInt32()
srcName = QtCore.QString()
stream >> srcName
srcX1 = stream.readInt32()
srcY1 = stream.readInt32()
srcType = QtCore.QString()
stream >> srcType
zoneSize = stream.readInt32()
srcHeight = stream.readInt32()
srcDiameter = stream.readInt32()
gasDepletion = stream.readInt32()
gasTemperature = stream.readInt32()
self.srcTableModel.ships.append(srcShip(equipment, srcCode, srcName, srcX1, srcY1, srcType, zoneSize, srcHeight, srcDiameter, gasDepletion, gasTemperature))
self.srcTableModel.reset()

for row in range(frmRowCount):
if stream.atEnd():
raise IOError, "Stream loading error!"
srcFrmCode = stream.readInt32()
frmCode = stream.readInt32()
formationSrcName = QtCore.QString()
stream >> formationSrcName
evolvingGasDepletion = stream.readInt32()
evolvingGasTemperature = stream.readInt32()
self.frmTableModel.ships.append(frmShip(srcFrmCode, frmCode, formationSrcName, evolvingGasDepletion, evolvingGasTemperature))
self.frmTableModel.reset()

for row in range(emsRowCount):
if stream.atEnd():
raise IOError, "Stream loading error!"
srcEmsCode = stream.readInt32()
frmEmsCode = stream.readInt32()
pollutanTCode = stream.readInt32()
pollutantTName = QtCore.QString()
emissionType = QtCore.QString()
stream >> pollutantTName >> emissionType
emissionConc = stream.readInt32()
emissionValue = stream.readInt32()
emissionVolume = stream.readInt32()
self.emsTableModel.ships.append(emsShip(srcEmsCode, frmEmsCode, pollutanTCode, pollutantTName, emissionType, emissionConc, emissionValue, emissionVolume))
self.emsTableModel.reset()

self.dirty = False
except (IOError, OSError), e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception

#--SRC--###########################################################################################################################################################################################

EQUIPMENT, SRCCODE, SRCNAME, SRCX1, SRCY1, SRCTYPE, ZONESIZE, SRCHEIGHT, SRCDIAMETER, GASDEPLETION, GASTEMPERATURE = range(11)

class srcShip(object):

def __init__(self, equipment, srcCode, srcName, srcX1, srcY1, srcType, zoneSize, srcHeight, srcDiameter, gasDepletion, gasTemperature):
self.equipment = QtCore.QString(equipment)
self.srcCode = srcCode
self.srcName = QtCore.QString(srcName)
self.srcX1 = srcX1
self.srcY1 = srcY1
self.srcType = QtCore.QString(srcType)
self.zoneSize = zoneSize
self.srcHeight = srcHeight
self.srcDiameter = srcDiameter
self.gasDepletion = gasDepletion
self.gasTemperature = gasTemperature



class srcTableModel(QtCore.QAbstractTableModel):

def __init__(self, fileName = QtCore.QString()):
super (srcTableModel, self).__init__()
self.ships = []
self.fileName = fileName
self.dirty = True
# self.srctypes = ('aaa', 'bbb', 'ccc')
# self.countries = set()

def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)
# return 5


def columnCount (self, index=QtCore.QModelIndex()):
return 11


def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == EQUIPMENT:
return (QtGui.QApplication.translate("MainWindow", "Виробництво", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCNAME:
return (QtGui.QApplication.translate("MainWindow", "Найменув. дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCX1:
return (QtGui.QApplication.translate("MainWindow", "X,м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCY1:
return (QtGui.QApplication.translate("MainWindow", "Y,м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCTYPE:
return (QtGui.QApplication.translate("MainWindow", "Тип дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == ZONESIZE:
return (QtGui.QApplication.translate("MainWindow", "Розмір СЗЗ", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCHEIGHT:
return (QtGui.QApplication.translate("MainWindow", "Висота дж., м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCDIAMETER:
return (QtGui.QApplication.translate("MainWindow", "Діаметер дж., м", None, QtGui.QApplication.UnicodeUTF8))
elif section == GASDEPLETION:
return (QtGui.QApplication.translate("MainWindow", "Витрата ПГВС, м3/с", None, QtGui.QApplication.UnicodeUTF8))
elif section == GASTEMPERATURE:
return (QtGui.QApplication.translate("MainWindow", "Темпер. ПГВС", None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)


def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships [index.row()]
column = index.column()
if role == QtCore.Qt.DisplayRole:
if column == EQUIPMENT:
return QtCore.QVariant(ship.equipment)
elif column == SRCCODE:
return QtCore.QVariant(ship.srcCode)
elif column == SRCNAME:
return QtCore.QVariant(ship.srcName)
elif column == SRCX1:
return QtCore.QVariant(ship.srcX1)
elif column == SRCY1:
return QtCore.QVariant(ship.srcY1)
elif column == SRCTYPE:
return QtCore.QVariant(ship.srcType)
elif column == ZONESIZE:
return QtCore.QVariant(ship.zoneSize)
elif column == SRCHEIGHT:
return QtCore.QVariant(ship.srcHeight)
elif column == SRCDIAMETER:
return QtCore.QVariant(ship.srcDiameter)
elif column == GASDEPLETION:
return QtCore.QVariant(ship.gasDepletion)
elif column == GASTEMPERATURE:
return QtCore.QVariant(ship.gasTemperature)
return


def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)


def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships [index.row()]
column = index.column()
if column == EQUIPMENT:
ship.equipment = value.toString()
elif column == SRCCODE:
value, ok = value.toInt()
if ok:
ship.srcCode = value
elif column == SRCNAME:
ship.srcName = value.toString()
elif column == SRCX1:
value, ok = value.toInt()
if ok:
ship.srcX1 = value
elif column == SRCY1:
value, ok = value.toInt()
if ok:
ship.srcY1 = value
elif column == SRCTYPE:
ship.srcType = value.toString()
elif column == ZONESIZE:
value, ok = value.toInt()
if ok:
ship.zoneSize = value
elif column == SRCHEIGHT:
value, ok = value.toInt()
if ok:
ship.srcHeight = value
elif column == SRCDIAMETER:
value, ok = value.toInt()
if ok:
ship.srcDiameter = value
elif column == GASDEPLETION:
value, ok = value.toInt()
if ok:
ship.gasDepletion = value
elif column == GASTEMPERATURE:
value, ok = value.toInt()
if ok:
ship.gasTemperature = value
self.dirty = True
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False


def insertRows (self, position, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, srcShip("Unknown", position + 1, "Unknown", 0, 0, "Unknown", 0, 0, 0, 0, 0))
self.endInsertRows()
self.dirty = True
return True


def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships[:position] + self.ships [position + rows:]
self.endRemoveRows()
self.dirty = True
return True


#--FRM--###########################################################################################################################################################################################

SRCFRMCODE, FRMCODE, FORMATIONSRCNAME, EVOLVINGGASDEPLETION, EVOLVINGGASTEMPERATURE = range (5)

class frmShip(object):

def __init__(self, srcFrmCode, frmCode, formationSrcName, evolvingGasDepletion, evolvingGasTemperature):
self.srcFrmCode = srcFrmCode
self.frmCode = frmCode
self.formationSrcName = QtCore.QString(formationSrcName)
self.evolvingGasDepletion = evolvingGasDepletion
self.evolvingGasTemperature = evolvingGasTemperature

class frmTableModel(QtCore.QAbstractTableModel):

def __init__(self, fileName = QtCore.QString()):
super (frmTableModel, self).__init__()
self.ships = []
self.fileName = fileName
self.dirty = True
# self.srcCodes = set ()
# self.countries = set()

def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)
# return 5


def columnCount (self, index=QtCore.QModelIndex()):
return 5


def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == SRCFRMCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. вик. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == FRMCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. утв. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == FORMATIONSRCNAME:
return (QtGui.QApplication.translate("MainWindow", "Найм. дж. утв.", None, QtGui.QApplication.UnicodeUTF8))
elif section == EVOLVINGGASDEPLETION:
return (QtGui.QApplication.translate("MainWindow", "Витрата ПГВС, м3/с", None, QtGui.QApplication.UnicodeUTF8))
elif section == EVOLVINGGASTEMPERATURE:
return (QtGui.QApplication.translate("MainWindow", "Темпер., 0С, ", None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)


def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships [index.row()]
column = index.column()
if role == QtCore.Qt.DisplayRole:
if column == SRCFRMCODE:
return QtCore.QVariant(ship.srcFrmCode)
elif column == FRMCODE:
return QtCore.QVariant(ship.frmCode)
elif column == FORMATIONSRCNAME:
return QtCore.QVariant(ship.formationSrcName)
elif column == EVOLVINGGASDEPLETION:
return QtCore.QVariant(ship.evolvingGasDepletion)
elif column == EVOLVINGGASTEMPERATURE:
return QtCore.QVariant(ship.evolvingGasTemperature)
return


def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)


def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships [index.row()]
column = index.column()
if column == SRCFRMCODE:
value, ok = value.toInt()
if ok:
ship.srcFrmCode = value
elif column == FRMCODE:
value, ok = value.toInt()
if ok:
ship.frmCode = value
elif column == FORMATIONSRCNAME:
ship.formationSrcName = value.toString()
elif column == EVOLVINGGASDEPLETION:
value, ok = value.toInt()
if ok:
ship.evolvingGasDepletion = value
elif column == EVOLVINGGASTEMPERATURE:
value, ok = value.toInt()
if ok:
ship.evolvingGasTemperature = value
self.dirty = True
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False


def insertRows (self, position, indexSrcCode, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, frmShip(indexSrcCode, position + 1, "Unknown", 0, 0))
self.endInsertRows()
self.dirty = True
return True


def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships[:position] + self.ships [position + rows:]
self.endRemoveRows()
self.dirty = True
return True

#--EMS--###########################################################################################################################################################################################

SRCEMSCODE, FRMEMSCODE, POLLUTANTCODE, POLLUTANTNAME, EMISSIONTYPE, EMISSIONCONC, EMISSIONVALUE, EMISSIONVOLUME = range (8)

class emsShip(object):

def __init__(self, srcEmsCode, frmEmsCode, pollutanTCode, pollutantTName, emissionType, emissionConc, emissionValue, emissionVolume):
self.srcEmsCode = srcEmsCode
self.frmEmsCode = frmEmsCode
self.pollutanTCode = pollutanTCode
self.pollutantTName = QtCore.QString(pollutantTName)
self.emissionType = QtCore.QString(emissionType)
self.emissionConc = emissionConc
self.emissionValue = emissionValue
self.emissionVolume = emissionVolume

class emsTableModel(QtCore.QAbstractTableModel):

def __init__(self, fileName = QtCore.QString()):
super (emsTableModel, self).__init__()
self.ships = []
self.fileName = fileName
self.dirty = True
# self.srcCodes = set ()
# self.countries = set()

def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)
# return 5


def columnCount (self, index=QtCore.QModelIndex()):
return 8


def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == SRCEMSCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. вик. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == FRMEMSCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. утв. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == POLLUTANTCODE:
return (QtGui.QApplication.translate("MainWindow", "Код ЗР", None, QtGui.QApplication.UnicodeUTF8))
elif section == POLLUTANTNAME:
return (QtGui.QApplication.translate("MainWindow", "Наймен. ЗР", None, QtGui.QApplication.UnicodeUTF8))
elif section == EMISSIONTYPE:
return (QtGui.QApplication.translate("MainWindow", "Тип викиду", None, QtGui.QApplication.UnicodeUTF8))
elif section == EMISSIONCONC:
return (QtGui.QApplication.translate("MainWindow", "Конц. ЗР, мг/м3", None, QtGui.QApplication.UnicodeUTF8))
elif section == EMISSIONVALUE:
return (QtGui.QApplication.translate("MainWindow", "Макс. викид, г/с", None, QtGui.QApplication.UnicodeUTF8))
elif section == EMISSIONVOLUME:
return (QtGui.QApplication.translate("MainWindow", "Річн. викид, т/рік ", None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)


def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships [index.row()]
column = index.column()
if role == QtCore.Qt.DisplayRole:
if column == SRCEMSCODE:
return QtCore.QVariant(ship.srcEmsCode)
elif column == FRMEMSCODE:
return QtCore.QVariant(ship.frmEmsCode)
elif column == POLLUTANTCODE:
return QtCore.QVariant(ship.pollutanTCode)
elif column == POLLUTANTNAME:
return QtCore.QVariant(ship.pollutantTName)
elif column == EMISSIONTYPE:
return QtCore.QVariant(ship.emissionType)
elif column == EMISSIONCONC:
return QtCore.QVariant(ship.emissionConc)
elif column == EMISSIONVALUE:
return QtCore.QVariant(ship.emissionValue)
elif column == EMISSIONVOLUME:
return QtCore.QVariant(ship.emissionVolume)
return


def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)


def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships [index.row()]
column = index.column()
if column == SRCEMSCODE:
value, ok = value.toInt()
if ok:
ship.srcEmsCode = value
elif column == FRMEMSCODE:
value, ok = value.toInt()
if ok:
ship.frmEmsCode = value
elif column == POLLUTANTCODE:
value, ok = value.toInt()
if ok:
ship.pollutanTCode = value
elif column == POLLUTANTNAME:
ship.pollutantTName = value.toString()
elif column == EMISSIONTYPE:
ship.emissionType = value.toString()
elif column == EMISSIONCONC:
value, ok = value.toInt()
if ok:
ship.emissionConc = value
elif column == EMISSIONVALUE:
value, ok = value.toInt()
if ok:
ship.emissionValue = value
elif column == EMISSIONVOLUME:
value, ok = value.toInt()
if ok:
ship.emissionVolume = value
self.dirty = True
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False


def insertRows (self, position, indexSrcCode, indexFrmCode, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, emsShip(indexSrcCode, indexFrmCode, 0, "Unknown", "Unknow", 0, 0, 0))
self.endInsertRows()
self.dirty = True
return True


def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships[:position] + self.ships [position + rows:]
self.endRemoveRows()
self.dirty = True
return True

#--DELEGATE--#######################################################################################################################################################################################


class srcShipDelegate(QtGui.QItemDelegate):

def __init__(self, parent=None):
super(srcShipDelegate, self).__init__(parent)

def createEditor(self, parent, option, index):
if index.column() == SRCTYPE:
editor = QtGui.QComboBox(parent)
editor.insertItem(1, QtGui.QApplication.translate("MainWindow", "Неорган.", None, QtGui.QApplication.UnicodeUTF8))
editor.insertItem(2, QtGui.QApplication.translate("MainWindow", "Організ.", None, QtGui.QApplication.UnicodeUTF8))
editor.insertItem(3, QtGui.QApplication.translate("MainWindow", "Основне", None, QtGui.QApplication.UnicodeUTF8))
editor.setEditable(False)
return editor
else:
QtGui.QItemDelegate.createEditor(self, parent, option, index)

def setEditorData(self, editor, index):
text = index.model().data(index, QtCore.Qt.DisplayRole).toString()
if index.column() == SRCTYPE:
i = editor.findText(text)
if i== -1:
i = 0
editor.setCurrentIndex(i)
else:
QtGui.QItemDelegate.setEditorData(self, editor, index)

def setModelData(self, editor, model, index):
if index.column() == SRCTYPE:
model.setData(index, QtCore.QVariant(editor.currentText()))
else:
QtGui.QItemDelegate.setModelData(self, editor, model, index)



if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MainForm()
myapp.show()
sys.exit(app.exec_())



Офлайн

#5 Март 16, 2011 08:52:09

Андрей Светлов
От:
Зарегистрирован: 2007-05-15
Сообщения: 3137
Репутация: +  14  -
Профиль   Адрес электронной почты  

QTableView делегат блокирует таблицу для редактирования

1. Есть изумительный bb tag code (писать в квадратных скобках).
2. Форматирование “поехало”.
3. Сайты вроде pastebin.com - простые и удобные.

import ui_tria - с этим тоже придется что-то сделать.
Поймите, либо я без усилий запускаю ваше творение и начинаю смотреть, что работает не так - или вообще не начинаю с ним возиться.
Если хотите - сократите до необходимого минимума (так всем будет проще).
Гадать - неприятно. Запустить и воспроизвести/увидеть ошибку - полдела сделано.



Офлайн

#6 Март 16, 2011 13:42:08

g-kit
От:
Зарегистрирован: 2009-11-16
Сообщения: 41
Репутация: +  0  -
Профиль   Отправить e-mail  

QTableView делегат блокирует таблицу для редактирования

сорри, провтыкал эти ньюансы…

атачментами не цыпляется…

выложил тут:
http://www.greenkit.net/Members/intereco/tria_009.py/download
http://www.greenkit.net/Members/intereco/ui_tria_004.py/download

проблема в первой таблице, можно добавить строчку (addSrc) и созерцать проблему: только одна ячейка подвергается редактированию - “Тип дж.” (с делегатом) - остальные просто не откликаются на щелчок мышью…



Отредактировано (Март 16, 2011 14:14:41)

Офлайн

#7 Март 18, 2011 01:44:58

Андрей Светлов
От:
Зарегистрирован: 2007-05-15
Сообщения: 3137
Репутация: +  14  -
Профиль   Адрес электронной почты  

QTableView делегат блокирует таблицу для редактирования

Прошу прощение за задержку.
В srcShipDelegate.createEditor поставьте return в else блоке. Это - всё.

А еще пишите по PEP-8 или хотя бы никогда не используйте табуляцию в исходниках :)



Офлайн

#8 Март 18, 2011 18:48:49

g-kit
От:
Зарегистрирован: 2009-11-16
Сообщения: 41
Репутация: +  0  -
Профиль   Отправить e-mail  

QTableView делегат блокирует таблицу для редактирования

какой коварный return! спасибо, помогло!

про табуляцию - понял, учту…



Офлайн

  • Начало
  • » GUI
  • » QTableView делегат блокирует таблицу для редактирования[RSS Feed]

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version