qitemdelegate

QStyledItemDelegate drawing custom widget failed

半城伤御伤魂 提交于 2019-12-07 12:56:11
问题 In one of my projects I'm using a QTableWidget in order to display some complex computational results. In order to increase the readability of the table I'm in need to display two aligned values inside of a single table cell. Later on I want to customize the widget even more by using colors or arrows etc.. For this I derived from QStyledItemDelegate and I called table ->setItemDelegate(new TwoNumbersDelegate) on my QTableWidget instance. For some reasons the QFrame is never display. I really

Qt QTableView draw border around active cells

妖精的绣舞 提交于 2019-12-07 03:22:38
问题 I'm trying to implement behavior similar Excel in a QTableView, where a border is painted around the entire current selection. I have tried this what feels like a hundred different ways and keep getting problems. I can draw the border easily enough, but remnants of the border are left whenever the selection changes. Here is one example I've tried in QTableView::paintEvent ... void MyTableView::paintEvent(QPaintEvent* event) { // call QTableView's paint event first so we can draw over it

Qt QTableView draw border around active cells

本小妞迷上赌 提交于 2019-12-05 06:37:59
I'm trying to implement behavior similar Excel in a QTableView, where a border is painted around the entire current selection. I have tried this what feels like a hundred different ways and keep getting problems. I can draw the border easily enough, but remnants of the border are left whenever the selection changes. Here is one example I've tried in QTableView::paintEvent ... void MyTableView::paintEvent(QPaintEvent* event) { // call QTableView's paint event first so we can draw over it QTableView::paintEvent(event); // activeSelection is a list of indexes that is updated in another function /

checkbox and itemdelegate in a tableview

霸气de小男生 提交于 2019-11-30 15:14:09
I'm doing an implementation of a CheckBox that inherits from QitemDelegate, to put it into a QTableView. the problem is that I get when inserted flush left and I need it centered. As I understand the method that is responsible for the Paint. I have it written as follows: void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { bool checkValue; QStyleOptionButton BtnStyle; BtnStyle.state = QStyle::State_Enabled; if(index.model()->data(index, Qt::DisplayRole).toBool() == true) { BtnStyle.state |= QStyle::State_On; checkValue = true;

Why pressing of “Tab” key emits only QEvent::ShortcutOverride event?

Deadly 提交于 2019-11-30 09:37:56
Background Hi guys. I've made a custom widget with QLineEdit and several QPushButtons to use it with custom item delegate: class LineEditor : public QWidget { public: explicit LineEditor(QWidget *parent = 0) : QWidget(parent) { setLayout(new QHBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); QLineEdit *edit = new QLineEdit(this); layout()->addWidget(edit); layout()->addWidget(new QPushButton(this)); layout()->addWidget(new QPushButton(this)); setFocusProxy(edit); } }; class PropertyDelegate : public QItemDelegate { public: QWidget *createEditor(QWidget *parent,

Qt Using Custom QItemDelegate for QTableView

我怕爱的太早我们不能终老 提交于 2019-11-29 21:57:34
I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate . It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know when my QItemDelegate is going to be utilized. when itemModel->setData() is used or when itemModel->setItem() . I would suspect setItem() because I reimplemented a QItemDelegate (emphasis on the "Item") but the tutorial uses setData() and it works fine. I know that if the specified QItemDelegate does not work it uses the default one but how do I now

checkbox and itemdelegate in a tableview

只谈情不闲聊 提交于 2019-11-29 21:56:35
问题 I'm doing an implementation of a CheckBox that inherits from QitemDelegate, to put it into a QTableView. the problem is that I get when inserted flush left and I need it centered. As I understand the method that is responsible for the Paint. I have it written as follows: void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { bool checkValue; QStyleOptionButton BtnStyle; BtnStyle.state = QStyle::State_Enabled; if(index.model()-

Qt - QTableView - Clickable button in table row

蹲街弑〆低调 提交于 2019-11-29 05:44:05
问题 I require a button/link within a table row of a QTableView . This is to open a dialog to allow that row to be edited more efficiently. After hours of looking on the web I am yet to find a decent example. I am aware that this is likely to be done using a QItemDelegate , but I am unsure how to have a functional widget within the row without forcing the item into edit mode first. Any help would be greatly appreciated. 回答1: You could emulate the functionality of a link by underlining the

Qt Using Custom QItemDelegate for QTableView

痴心易碎 提交于 2019-11-28 17:17:43
问题 I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate . It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know when my QItemDelegate is going to be utilized. when itemModel->setData() is used or when itemModel->setItem() . I would suspect setItem() because I reimplemented a QItemDelegate (emphasis on the "Item") but the tutorial uses setData() and it works

Paint widget directly on QListView with QStyledItemDelegate::paint()

一个人想着一个人 提交于 2019-11-28 09:56:16
问题 After hours of work, I'm able to paint a widget on QListView . However, the painting is done through a QPixmap . The widget appears, and I can see a progress bar. However, it's a little "pixelated" (due to using QPixmap ). Is it possible to paint directly as a normal widget? That's my question. The following is what I do: void FileQueueItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QPaintDevice* original_pdev_ptr = painter->device(