from aa import Ui_Form
from PyQt4.Qt import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sys import *
class A(QWidget,Ui_Form):
    def __init__(self):
        super(A,self).__init__()
        self.setupUi(self)
        self.Button.clicked.connect(self.aaa)
        self.Box.stateChanged.connect(self.selectaa)
        #self.Button.installEventFilter(self)
        self.Button.setCheckable(True)
    def eventFilter(self,watched,event):
        if watched == self.Button:
            if event.type() == QEvent.MouseButtonPress:
                mouseEvent = QMouseEvent(event)
                if mouseEvent.buttons() == Qt.LeftButton:
                    print 'left'

else:
                    print 'about'

return QWidget.eventFilter(self,watched,event)
    def aaa(self):
        text=self.Edit.text()
        row1=self.table1.rowCount()
        self.table1.insertRow(row1)
        item=QTableWidgetItem(text)
        # item.setTextAlignment(Qt.AlignLeft|Qt.AlignCenter)
        # item.setBackgroundColor(Qt.red)
        try:
            self.table1.setItem(row1,0,item)
            self.Box.setCheckState(Qt.Unchecked)
            self.table1.item(row1,0).setCheckState(Qt.Unchecked)
            if text.isEmpty():
                self.table1.setRowCount(row1)
                self.table1.item(row1,0).setData(10,QVariant())
            for i in range(row1):
                if self.table1.item(i,0).isSelected()!=False:
                    self.table1.item(i,0).setCheckState(Qt.Checked)
        except:
            QMessageBox.information(self,u'警告',u'edit或者表格中为空')
    def selectaa(self):
        box=self.Box.isChecked()
        row=self.table1.rowCount()
        col=self.table1.columnCount()
        for i in range(row):
            for j in range(col):
                if self.table1.item(i,0):
                    if box:
                        self.table1.item(i,0).setSelected(True)
                        self.table1.item(i,0).setCheckState(Qt.Checked)
                    else:
                        self.table1.item(i,0).setCheckState(Qt.Unchecked)
app=QApplication([])
a=A()
a.show()
exit(app.exec_())

下面是截图

qt下面例子学习(部分功能)的更多相关文章

  1. QT blockingmaster例子学习

    dialog.h: #ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include "masterthread.h&q ...

  2. (转)Qt Model/View 学习笔记 (七)——Delegate类

    Qt Model/View 学习笔记 (七) Delegate  类 概念 与MVC模式不同,model/view结构没有用于与用户交互的完全独立的组件.一般来讲, view负责把数据展示 给用户,也 ...

  3. (转)Qt Model/View 学习笔记 (五)——View 类

    Qt Model/View 学习笔记 (五) View 类 概念 在model/view架构中,view从model中获得数据项然后显示给用户.数据显示的方式不必与model提供的表示方式相同,可以与 ...

  4. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  5. 数百个 HTML5 例子学习 HT 图形组件 – 3D 建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  6. 数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇

    <数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇>一文让读者了解了 HT的 2D 拓扑图组件使用,本文将对 HT 的 3D 功能做个综合性的介绍,以便初学者可快速上手使用 HT ...

  7. 数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇

    HT 是啥:Everything you need to create cutting-edge 2D and 3D visualization. 这口号是当年心目中的产品方向,接着就朝这个方向慢慢打 ...

  8. Qt 智能指针学习(7种指针)

    Qt 智能指针学习 转载自:http://blog.csdn.net/dbzhang800/article/details/6403285 从内存泄露开始? 很简单的入门程序,应该比较熟悉吧 ^_^ ...

  9. HTML5 例子学习 HT 图形组件

    HTML5 例子学习 HT 图形组件 HT 是啥:Everything you need to create cutting-edge 2D and 3D visualization. 这口号是当年心 ...

随机推荐

  1. Heritrix源码分析(十四)

    近段时间在搞定Lucene的一些问题,所以Heritrix源码分析暂时告一段落.今天下午在群里有同学提到了Heritrix异常终止的问题以及让Heritrix不停的抓取(就是抓完一遍后载入种子继续抓取 ...

  2. linux程序自启动和新建linux服务的方法

    1 linux创建自启动程序    自启动的两种方法,都经过自己测试.1.1 自启动程序方法1:    在etc/rc.local在里面加入/home/robin/code/autoruntest & ...

  3. Log4Qt使用(三)在DailyRollingFileAppender类中增加属性mMaxBackupIndex

    在Log4Qt中存在一个比较大的问题,当使用 DailyRollingFileAppender对日志进行输出时,会无限输出文件,也就是说,当系统运行很久时,日志文件有可能很大,大到无法想象.因此,很多 ...

  4. Vim的设置和使用——编程者

    一.第一个插件:Ctags 当我们看到一个陌生的变量或者函数,我们总想知道它的含义,因此,快速找到它的定义很重要.Ctags插件中的"Ctrl+]"快捷键就可以做到. 二.教你高效 ...

  5. 【录音】Android录音--AudioRecord、MediaRecorder

    Android提供了两个API用于实现录音功能:android.media.AudioRecord.android.media.MediaRecorder. 网上有很多谈论这两个类的资料.现在大致总结 ...

  6. 初探R语言——R语言笔记

    R语言使用 <-  赋值 # 作为注释符号 c()函数用于作为向量赋值,例如age<-c(1,2,3,4,5) mean()用于求向量的平均值 sd()求向量的标准差 cor(a,b)求a ...

  7. jsp DAO设计模式

    DAO(Data Access Objects)设计模式是属于J2EE体系架构中的数据层的操作. 一.为什么要用DAO? 比较在JSP页面中使用JDBC来连接数据库,这样导致了JSP页面中包含了大量的 ...

  8. Sass函数--字符串函数

    Sass的函数简介在 Sass 中除了可以定义变量,具有 @extend.%placeholder 和 mixins 等特性之外,还自备了一系列的函数功能.其主要包括: ● 字符串函数 ● 数字函数 ...

  9. js中关于一个数组中最大、最小值以及它们的下标的输出的一种解决办法

    今天在学习js中的数组时,遇到的输出一个数组中最大.最小值以及它们的下表,以下是自己的解决方法! <script type="text/javascript"> var ...

  10. noip2015运输计划

    二分+LCA+查分前缀和 #include<iostream> #include<cstring> #include<cstdio> #include<alg ...