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. 【更新日志】售后CP更新日志

    记录一下: [售后CP更新日志] ============================================ 更新时间:[-- :] 更新内容: .版本升级,框架升级,框架升级版本3. ...

  2. onActivityResult不执行 或者 onActivityResult的解决方法

    开发人员都知道,可以通过使用 startActivityForResult() 和 onActivityResult() 方法来传递或接收参数.然而在一次使用中,还没等到被调用的 Activity 返 ...

  3. Linux下Weblogic域的创建过程

    环境介绍:操作系统 :Redhat 5.5Weblogic :英文版 8.1.6 Weblogic安装目录 :/weblogic 一.域的建立执行下面语句进入weblogic的bin目录: cd /w ...

  4. coco2d-html5制作弹弓射鸟第一部分---橡皮筋

    一.写在前面的话 最近在学习cocos2d-html5方面的知识,一直想从事游戏方面的工作,自己也找了好多资料.网上关于cocos2d-html5的教程真的不多,也只有自己摸索,慢慢看示例代码.由于本 ...

  5. Java基础知识强化62:Arrays工具类之概述和使用

    1. Arrays工具类: Arrays这个类包含操作数组(比如排序和查找)的各种方法. 2. Arrays的方法: (1)toString方法:把数组转成字符串 public static Stri ...

  6. 内容观察者 ContentObserver 监听短信、通话记录数据库 挂断来电

    Activity public class MainActivity extends ListActivity {     private TextView tv_info;     private  ...

  7. for语句应用:乘法表

    乘法表: for语句应用: 1: 2: public class chengfa { 3: public static void main(String[] args) { 4: //int i; 5 ...

  8. ORACLE之SQL语句内部解析过程【weber出品】

    一.客户端通过监听连接到数据库,数据库开启一个server process进程来接收客户端传过来的sql. 1.这条sql语句从来都没有被执行过.(硬解析) 2.这条sql语句被执行过.(软解析) 二 ...

  9. angularjs中关于ng-if的一些理论

    ng-if简介: ● 使用ng-if指令可以完全根据表达式的值在DOM中生成或移除一个元素.如果赋值给ng-if 的表达式的值是false,那对应的元素将会从DOM中移除,否则对应元素的一个克隆将被重 ...

  10. 武汉科技大学ACM :1003: 零起点学算法67——统计字母数字等个数

    Problem Description 输入一串字符,统计这串字符里的字母个数,数字个数,空格字数以及其他字符(最多不超过100个字符) Input 多组测试数据,每行一组 Output 每组输出一行 ...