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. [React Testing] Conditional className with Shallow Rendering

    Often our components have output that shows differently depending on the props it is given; in this ...

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

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

  3. 小学生之KTV播放原理

    第一步: 创建一个Song类 //歌曲名称 public  string SongName { get; set; } //歌曲路劲 public string SongPath { get; set ...

  4. Hyper-v虚拟机上网

    Windows 8中内置的Hyper-V管理器可以说给许多人带来了惊喜!在Hyper-V管理器强大的同时,也同样面临着设置中一些不可避免的麻烦.有人说,Hyper-V虚拟机联网麻烦,其实,只要掌握了技 ...

  5. 基于java callable及future接口解决生产者消费者问题

    这两天复习java线程时,把java里面的线程基本知识点与jdk1.5以后新添加的一些类的使用都了解了一下,借用生产者消费者的问题来将他们实践一下. 题目:(题目在csdn一大牛的空间找的) 生产者- ...

  6. C#System.Net.Mail采用简单邮件传输协议发送邮件

    引用: using System.Net.Mail; public class EmailHelper { public static bool SendEmail(string title, str ...

  7. MyEclipse笔记(2):debug的使用

    对于程序代码而言,学会调debug是重中之重,依此,掌握该技巧 以算1到50的和的代码为例: package com.front.action; public class debug { public ...

  8. linux mint 下mysql中文支持问题

    一.mysql默认不支持中文,它的server和db默认是latin1编码.所以我们要将其改变为utf-8编码,因为utf-8包含了地球上大部分语言的二进制编码 1.关闭mysql服务 sudo /e ...

  9. js学习笔记——数组方法

    join() 把数组中所有元素转化为字符串并连接起来,并返回该字符串, var arr=[1,2,3]; var str=arr.join("#"); //str="1# ...

  10. [Mugeda HTML5技术教程之2] Mugeda HTML5富媒体平台简介

    [Mugeda HTML5技术教程之2] Mugeda HTML5动画平台简介 摘要:Mugeda提供基于云的平台,供开发人员和设计人员快速的开发.发布和统计基于HTML5的,包含丰富动画和交互的移动 ...