QPushButton * pBtn = new QPushButton()
2 链接信号与曹
connect(pBtn, SIGNAL(clicked()), this, SLOT(OnBtnClicked()))
3 按钮添加到单元格内
table->setCellWidget(0,0,pBtn)//如果点击按钮出现崩溃现象,就添加QTableWidgetItem 到按钮的那个单元格
4 实现按钮的事件
void myPic::OnBtnClicked(void) { QPushButton * senderObj=qobject_cast<QPushButton *>(sender()) if(senderObj == 0) { return } QModelIndex index =table->indexAt(QPoint(senderObj->frameGeometry().x(),senderObj->frameGeometry().y())) int row=index.row() qDebug()<<"row:"<<row}
可以给你一个思路,在两个listview中间放一个panel作为画线的地方,用mousedown,mouseMove和mouseUp,这个对你来说应该不难了 关键是获取这两行数据 在listview里面有一个AutoScrollOffset判断当前滚动条所在位置,然后再结合你连线的起始点的setPlainText()
toPlainText()
setHtml()
toHtml()
clear()
'''
【简介】
PyQt5中 QTextEdit例子
'''
from PyQt5.QtWidgets import QApplication, QWidget, QTextEdit, QVBoxLayout, QPushButton
import sys
class TextEditDemo(QWidget):
def init (self, parent=None):
super(TextEditDemo, self). init (parent)
self.setWindowTitle("QTextEdit 例子")
self.resize(300, 270)
self.textEdit = QTextEdit()
self.btnPress1 = QPushButton("显示文本")
self.btnPress2 = QPushButton("显示HTML")
layout = QVBoxLayout()
layout.addWidget(self.textEdit)
layout.addWidget(self.btnPress1)
layout.addWidget(self.btnPress2)
self.setLayout(layout)
self.btnPress1.clicked.connect(self.btnPress1_Clicked)
self.btnPress2.clicked.connect(self.btnPress2_Clicked)
if name == " main ":
app = QApplication(sys.argv)
win = TextEditDemo()
win.show()
sys.exit(app.exec_())
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)