首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QML,Qt4.8:如何同时启用openGl和Chromeless?

QML,Qt4.8:如何同时启用openGl和Chromeless?
EN

Stack Overflow用户
提问于 2012-04-19 20:02:01
回答 1查看 1.4K关注 0票数 0

下面是我的主要内容

代码语言:javascript
复制
#include <QtGui/QApplication>
#include <QtOpenGL>
#include <QDeclarativeView>
#include <QDeclarativeEngine>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    // Depending on which is the recommended way for the platform, either use
    // opengl graphics system or paint into QGLWidget.
    #ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
        QApplication::setGraphicsSystem("opengl");
    #endif

        QApplication a(argc, argv);

    #ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
        QGLFormat format = QGLFormat::defaultFormat();
        format.setSampleBuffers(false);
        format.setSwapInterval(1);
        QGLWidget* glWidget = new QGLWidget(format);
        glWidget->setAutoFillBackground(false);
    #endif

        MainWindow w(glWidget);
    w.show();

    return a.exec();
}

和我用来打开QML的文件

代码语言:javascript
复制
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);
  setAttribute(Qt::WA_TranslucentBackground);
  setStyleSheet("background:transparent;");
  qmlRegisterType<QGraphicsBlurEffect>("Effects",1,0,"Blur");
  /* turn off window decorations */
  setWindowFlags(Qt::FramelessWindowHint);



  ui = new QDeclarativeView;
  ui->setSource(QUrl("qrc:/assets/ui.qml"));

 // ui->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);


  setCentralWidget(ui);
}

MainWindow::~MainWindow()
{
    delete ui;
}

代码语言:javascript
复制
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtDeclarative>
#include <QtDeclarative/QDeclarativeView>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    QDeclarativeView *ui;
};

#endif // MAINWINDOW_H

我尝试启用Open GL,但我什么也看不到,当我在main中注释行时,在我看来,我看到了我的CHROMELESS窗口

代码语言:javascript
复制
Qml debugging is enabled. Only use this in a safe environment!
ShaderEffectItem::paint - OpenGL not available 

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2012-10-01 01:48:29

根据这个:http://qt-project.org/faq/answer/opengl_and_translucent_background_do_not_work_together_due_to_a_limitation

这似乎是不可能的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10227614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档