Qt

Qt学习 开源项目

QML

qml online

/* test.qml */

import QtQuick 2.0

Rectangle {
    id: test
    width: 100; height: 30

    Text {
        anchors.fill:parent;
        text: textData;
    }
}
from PyQt5.QtQuick import  QQuickView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl

app = QApplication([])

view = QQuickView()
rootContext = view.rootContext()
rootContext.setContextProperty("textData", "Hello world")
view.setSource(QUrl("test.qml"))
view.show()
app.exec_()


PyQt4
Nullege is a search engine for Python source code

Qt Style Sheets Examples

PyQt 学习示例

git clone --depth 1  https://github.com/pyqt/examples.git

播放器

QMultimedia
QCamera
$ sudo apt-get install smplayer
QT环境搭建: QT-4.8 在windows下的使用
http://blog.csdn.net/qq_22122811/article/details/63684008

知识点

// QTableWidget
this->ui->tablewidget->setSelectionBehavior(QAbstractItemView::SelectRows);  //单击选择一行
this->ui->tablewidget->setSelectionMode(QAbstractItemView::SingleSelection); //设置只能选择一行,不能多行选中
this->ui->tablewidget->setEditTriggers(QAbstractItemView::NoEditTriggers);   //设置每行内容不可更改
this->ui->tablewidget->setAlternatingRowColors(true);                        //设置隔一行变一颜色,即:一灰一白
# install qt4
$ sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer -y --force-yes

# qtcreator-3.5.1 depends
$ sudo apt-get install libgstreamer-plugins-base0.10-0

StyleSheet

sudo apt-get install ttf-wqy-zenhei fonts-wqy-microhei #安装字体

fc-list # 查看字体命令
font: bold;  是否粗体显示
border-image:"";  用来设定边框的背景图片。
border-radius:5px;  用来设定边框的弧度。可以设定圆角的按钮
border-width: 1px;  边框大小


font-family:"微软雅黑";  来设定字体所属家族,
font-size:20px;      来设定字体大小
font-style:"";       来设定字体样式
font-weight:20px;    来设定字体深浅

background-color: green;  设置背景颜色
background:transparent;   设置背景为透明
color:rgb(241, 70, 62);   设置前景颜色
selection-color:rgb(241, 70, 62);  用来设定选中时候的颜色

qproperty-alignment: AlignCenter; /*居中*/
qproperty-text: '文字';
qproperty-wordWrap: true; /* 自动换行*/



 min-height: 32px;
 max-height: 32px;
 min-width: 80px;
 max-width: 80px;
 padding: 5px;


可以使用border-top,border-right,border-bottom,border-left分别设定按钮的上下左右边框,
同样有border-left-color, border-left-style, border-left-width.等分别来设定他们的颜色,样式和宽度
/************************
*   横向 Slider
************************/
QSlider::groove:horizontal {
        border: 1px solid #4A708B;
        background: #C0C0C0;
        height: 5px;
        border-radius: 1px;
        padding-left:-1px;
        padding-right:-1px;
}

QSlider::sub-page:horizontal {
        background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
            stop:0 #B1B1B1, stop:1 #c4c4c4);
        background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,
            stop: 0 #5DCCFF, stop: 1 #1874CD);
        border: 1px solid #4A708B;
        height: 10px;
        border-radius: 2px;
}

QSlider::add-page:horizontal {
        background: #575757;
        border: 0px solid #777;
        height: 10px;
        border-radius: 2px;
}

QSlider::handle:horizontal {
    background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
    stop:0.6 #45ADED, stop:0.778409 rgba(255, 255, 255, 255));

    width: 11px;
    margin-top: -3px;
    margin-bottom: -3px;
    border-radius: 5px;
}

QSlider::handle:horizontal:hover {
    background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #2A8BDA,
    stop:0.778409 rgba(255, 255, 255, 255));

    width: 11px;
    margin-top: -3px;
    margin-bottom: -3px;
    border-radius: 5px;
}

QSlider::sub-page:horizontal:disabled {
        background: #00009C;
        border-color: #999;
}

QSlider::add-page:horizontal:disabled {
        background: #eee;
        border-color: #999;
}

QSlider::handle:horizontal:disabled {
        background: #eee;
        border: 1px solid #aaa;
        border-radius: 4px;
}


/************************
*   纵向 Slider
************************/

QSlider::groove:vertical {
        border: 1px solid #4A708B;
        background: #C0C0C0;
        width: 5px;
        border-radius: 1px;
        padding-left:-1px;
        padding-right:-1px;
        padding-top:-1px;
        padding-bottom:-1px;
}

QSlider::sub-page:vertical {
        background: #575757;
        border: 1px solid #4A708B;
        border-radius: 2px;
}

QSlider::add-page:vertical {
        background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
            stop:0 #c4c4c4, stop:1 #B1B1B1);
        background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,
            stop: 0 #5DCCFF, stop: 1 #1874CD);
        border: 0px solid #777;
        width: 10px;
        border-radius: 2px;
}

QSlider::handle:vertical
{
        background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.6 #45ADED,
        stop:0.778409 rgba(255, 255, 255, 255));

        height: 11px;
        margin-left: -3px;
        margin-right: -3px;
        border-radius: 5px;
}

QSlider::sub-page:vertical:disabled {
        background: #00009C;
        border-color: #999;
}

QSlider::add-page:vertical:disabled {
        background: #eee;
        border-color: #999;
}

QSlider::handle:vertical:disabled {
        background: #eee;
        border: 1px solid #aaa;
        border-radius: 4px;
}