void Dialog_editPersInfo::inserSkillIntoList(QString skillName, int skillId) { QLabel* skillVal = new QLabel(skillName); QPushButton* delButton = new QPushButton(QString("Видалити")); delButton->setCursor(Qt::PointingHandCursor); int rowNumber = ui->layout_persSkills->rowCount(); ui->layout_persSkills->addWidget(skillVal, rowNumber, 0); //ui->layout_persSkills->addWidget(delButton, rowNumber, 1); skills.append(skillId); connect(delButton, SIGNAL(clicked()), this, SLOT( removeSkill() )); }
void QCustomTableWidget::onHHeaderClicked(int index, const QPoint &position) { QAction *action = hMenu->exec(position); if (action == actionHAdd) { addSkill(index); } else if (action == actionHRemove) { removeSkill(index); } else if (action == actionHEdit) { editSkill(index); } }
void QCustomTableWidget::mousePressEvent(QMouseEvent *e) { int rowPosition, columnPosition; QTableWidgetItem *qtwitem = itemAt(e->pos()); switch (e->button()) { case Qt::LeftButton: { if (qtwitem == NULL || qtwitem->isSelected()) { setCurrentItem(NULL); } else { QTableWidget::mousePressEvent(e); } break; } case Qt::RightButton: { if (qtwitem == NULL) { if (rowCount()!=0 && columnCount()!=0) { break; } else { rowPosition = rowCount()-1; columnPosition = columnCount()-1; } } else { setCurrentItem(qtwitem); rowPosition = currentRow(); columnPosition = currentColumn(); } QTableWidget::mousePressEvent(e); bool null = (qtwitem!=NULL); actionRemoveColumn->setVisible(null); actionEditColumn->setVisible(null); actionRemoveRow->setVisible(null); actionEditRow->setVisible(null); QAction* action = menu->exec(e->globalPos()); if (action == actionAddColumn) { addSkill(columnPosition); } else if (action == actionRemoveColumn) { if (qtwitem != NULL) { removeSkill(columnPosition); } } else if (action == actionEditColumn) { if (qtwitem != NULL) { editSkill(columnPosition); } } else if (action == actionAddRow) { addCharacter(rowPosition); } else if (action == actionRemoveRow) { if (qtwitem != NULL) { removeCharacter(rowPosition); } } else if (action == actionEditRow) { if (qtwitem != NULL) { editCharacter(rowPosition); } } break; } default: break; } }