Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: вопрос по окраске tableView
Форум на CrossPlatform.RU > Библиотеки > Qt > Qt Система рисования. Печать
vanvo
Прошу подсказать, почему не работает строчка
modelInstruction->setData(modelInstruction->index(0, 0), Qt::blue, Qt::BackgroundRole);


Вот кусок кода:
QSqlQueryModel *modelInstruction = new QSqlQueryModel;
tableViewInfo->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
str = "SELECT instruction.inf, doctors.surname, instruction.time FROM instruction, doctors WHERE instruction.iduser = %1 AND instruction.iddoctor = doctors.id ORDER BY instruction.id DESC LIMIT 30;";
str = str.arg(id);
modelInstruction->setQuery(str);
modelInstruction->setHeaderData(0, Qt::Horizontal, tr("Doctor's \ninstruction"), Qt::DisplayRole);
modelInstruction->setHeaderData(1, Qt::Horizontal, tr("Doctor's\n surname"), Qt::DisplayRole);
modelInstruction->setHeaderData(2, Qt::Horizontal, tr("Departure\ntime"), Qt::DisplayRole);
modelInstruction->setData(modelInstruction->index(0, 0), Qt::blue, Qt::BackgroundRole);
tableViewInfo->setModel(modelInstruction);
SABROG
А если заменить Qt::blue на QColor(Qt::blue) ?

Скорее всего не поможет, тогда тебе сюда: http://www.qtcentre.org/forum/f-newbie-4/t...egate-2805.html
vanvo
Цитата(SABROG @ 12.5.2009, 22:24) *
Скорее всего не поможет, тогда тебе сюда: http://www.qtcentre.org/forum/f-newbie-4/t...egate-2805.html

Да, QColor не помог... А вот ссылку на тему ты подкинул очень дельную спасибо :) Хотелось бы все-равно узнать, почему данная строчка не работает...
EhTemka
Цитата(vanvo @ 12.5.2009, 23:18) *
Хотелось бы все-равно узнать, почему данная строчка не работает...


Про QSqlQueryModel написано в ассистанте

Цитата
The model is read-only by default. To make it read-write, you must subclass it and reimplement setData() and flags(). Another option is to use QSqlTableModel, which provides a read-write model based on a single database table.


То есть, она только для чтения.
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Форум IP.Board © 2001-2024 IPS, Inc.