设置是否显示对象 ,用display 和visibility

display 属性规定元素应该生成的框的类型。


说明

这个属性用于定义建立布局时元素生成的显示框类型。对于 HTML 等文档类型,如果使用 display 不谨慎会很危险,因为可能违反 HTML 中已经定义的显示层次结构。对于 XML,由于 XML 没有内置的这种层次结构,所有 display 是绝对必要的。
注释:CSS2 中有值 compact 和 marker,不过由于缺乏广泛的支持,已经从 CSS2.1 中去除了。
默认值: inline
继承性: no
版本:         CSS1
JavaScript 语法: object.style.display="inline"


可能的值

描述
none 此元素不会被显示。
block 此元素将显示为块级元素,此元素前后会带有换行符。
inline 默认。此元素会被显示为内联元素,元素前后没有换行符。
inline-block 行内块元素。(CSS2.1 新增的值)
list-item 此元素会作为列表显示。
run-in 此元素会根据上下文作为块级元素或内联元素显示。
compact CSS 中有值 compact,不过由于缺乏广泛支持,已经从 CSS2.1 中删除。
marker CSS 中有值 marker,不过由于缺乏广泛支持,已经从 CSS2.1 中删除。
table 此元素会作为块级表格来显示(类似 <table>),表格前后带有换行符。
inline-table 此元素会作为内联表格来显示(类似 <table>),表格前后没有换行符。
table-row-group 此元素会作为一个或多个行的分组来显示(类似 <tbody>)。
table-header-group 此元素会作为一个或多个行的分组来显示(类似 <thead>)。
table-footer-group 此元素会作为一个或多个行的分组来显示(类似 <tfoot>)。
table-row 此元素会作为一个表格行显示(类似 <tr>)。
table-column-group 此元素会作为一个或多个列的分组来显示(类似 <colgroup>)。
table-column 此元素会作为一个单元格列显示(类似 <col>)
table-cell 此元素会作为一个表格单元格显示(类似 <td> 和 <th>)
table-caption 此元素会作为一个表格标题显示(类似 <caption>)

inherit 规定应该从父元素继承 display 属性的值。

 伦理片 http://www.dotdy.com/

visibility

语法:  visibility : inherit | visible | collapse | hidden  
参数: 
 inherit 继承上一个父对象的可见性
visible 对象可视
hidden 对象隐藏 
说明:  
设置或检索是否显示对象。与display属性不同,此属性为隐藏的对象保留其占据的物理空间。
如果希望对象为可视,其父对象也必须是可视的。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在QML中使用OpenGL ES进行渲染可以通过QQuickFramebufferObject类实现。QQuickFramebufferObject是一个QML元素,它允许你通过OpenGL ES渲染,可以将OpenGL ES渲染结果直接显示到QML界面上。 使用QQuickFramebufferObject需要自定义一个QQuickFramebufferObject子类,并实现createFramebufferObject()和Renderer两个函数。其中,createFramebufferObject()函数创建一个QOpenGLFramebufferObject对象,用于渲染,Renderer则负责OpenGL ES渲染。 在实现Renderer时,可以在rendererInitialized()函数中创建Pbuffer表面,将其和OpenGL ES上下文绑定。在render()函数中,可以使用OpenGL ES渲染Pbuffer表面,然后将渲染结果绘制到QOpenGLFramebufferObject对象中。最后,在synchronize()函数中可以将QQuickFramebufferObject元素和OpenGL ES上下文同步,确保渲染结果正确显示。 以下是一个简单的QQuickFramebufferObject子类的示例代码: ```qml import QtQuick 2.0 import QtQuick.Window 2.0 import QtQuick.Controls 2.0 import QtQuick.Scene3D 2.0 import QtQuick.Particles 2.0 Item { width: 640 height: 480 MyFramebuffer { anchors.fill: parent } } // MyFramebuffer.qml import QtQuick 2.0 import QtQuick.Window 2.0 import QtQuick.Controls 2.0 import QtQuick.Scene3D 2.0 import QtQuick.Particles 2.0 Item { width: 640 height: 480 MyFramebufferObject { id: fbo anchors.fill: parent } Rectangle { anchors.fill: parent color: "white" opacity: 0.7 } } // MyFramebufferObject.qml import QtQuick 2.0 import QtQuick.Window 2.0 import QtQuick.Controls 2.0 import QtQuick.Scene3D 2.0 import QtQuick.Particles 2.0 import QtQuick.Controls.Material 2.0 import QtQuick.Controls.impl 2.0 Item { width: 640 height: 480 property int textureWidth: 512 property int textureHeight: 512 // Create Pbuffer surface and OpenGL ES context function createFramebufferObject(size) { var fbo = new QOpenGLFramebufferObject(size); var context = Qt.createQmlObject("import QtQuick 2.0; import QtQuick.Window 2.0; Qt.createQmlObject('Window { visible: false; width: 1; height: 1; visibility: Window.Hidden; }', parent, 'PbufferWindow')"); var surface = context.createSurface(fbo.handle); context.makeCurrent(surface); return {fbo: fbo, context: context}; } // Renderer for OpenGL ES function MyFramebufferRenderer() { var pbufferSurface = null; var context = null; var program = null; var vertexBuffer = null; var indexBuffer = null; var texture = null; var textureLocation = -1; var vertexLocation = -1; var texCoordLocation = -1; var transformLocation = -1; var matrix = mat4.create(); this.rendererInitialized = function() { // Create Pbuffer surface and OpenGL ES context pbufferSurface = eglCreatePbufferSurface(EGL_DEFAULT_DISPLAY, EGL_NO_CONFIG, [EGL_WIDTH, textureWidth, EGL_HEIGHT, textureHeight, EGL_NONE]); context = eglCreateContext(EGL_DEFAULT_DISPLAY, EGL_NO_CONFIG, EGL_NO_CONTEXT, null); eglMakeCurrent(EGL_DEFAULT_DISPLAY, pbufferSurface, pbufferSurface, context); // Initialize OpenGL ES resources program = glCreateProgram(); var vertexShader = glCreateShader(GL_VERTEX_SHADER); var fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(vertexShader, "attribute vec4 vertex; attribute vec2 texCoord; uniform mat4 transform; varying vec2 texCoordVar; void main() { gl_Position = transform * vertex; texCoordVar = texCoord; }"); glCompileShader(vertexShader); glShaderSource(fragmentShader, "precision mediump float; uniform sampler2D texture; varying vec2 texCoordVar; void main() { gl_FragColor = texture2D(texture, texCoordVar); }"); glCompileShader(fragmentShader); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); glUseProgram(program); vertexLocation = glGetAttribLocation(program, "vertex"); texCoordLocation = glGetAttribLocation(program, "texCoord"); textureLocation = glGetUniformLocation(program, "texture"); transformLocation = glGetUniformLocation(program, "transform"); var vertices = new Float32Array([-1.0, -1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 0.0, 1.0]); var indices = new Uint16Array([0, 1, 2, 0, 2, 3]); vertexBuffer = glCreateBuffer(); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW); indexBuffer = glCreateBuffer(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices, GL_STATIC_DRAW); texture = glCreateTexture(); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } this.render = function() { // Render Pbuffer surface glViewport(0, 0, textureWidth, textureHeight); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glEnableVertexAttribArray(vertexLocation); glVertexAttribPointer(vertexLocation, 4, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); glEnableVertexAttribArray(texCoordLocation); glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glUniformMatrix4fv(transformLocation, 1, false, matrix); glUniform1i(textureLocation, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); } this.releaseResources = function() { // Release OpenGL ES resources glDeleteProgram(program); glDeleteBuffers(1, [vertexBuffer]); glDeleteBuffers(1, [indexBuffer]); glDeleteTextures(1, [texture]); eglDestroyContext(EGL_DEFAULT_DISPLAY, context); eglDestroySurface(EGL_DEFAULT_DISPLAY, pbufferSurface); } } // Create framebuffer object and renderer MyFramebufferRenderer.prototype = new QQuickFramebufferObject.Renderer; MyFramebufferObject { id: myFbo width: textureWidth height: textureHeight antialiasing: true textureWidth: 512 textureHeight: 512 framebufferObject: createFramebufferObject(Qt.size(textureWidth, textureHeight)) renderer: MyFramebufferRenderer {} } } ``` 这个示例将一个自定义的QQuickFramebufferObject元素添加到界面中,然后在这个元素中创建一个Pbuffer表面,并将其和OpenGL ES上下文绑定。在渲染时,将Pbuffer表面渲染到QOpenGLFramebufferObject对象中,并通过QQuickFramebufferObject元素显示出来。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值