下面是我的主要内容
#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的文件
#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;
}和
#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窗口
Qml debugging is enabled. Only use this in a safe environment!
ShaderEffectItem::paint - OpenGL not available 我做错了什么?
发布于 2012-10-01 01:48:29
根据这个:http://qt-project.org/faq/answer/opengl_and_translucent_background_do_not_work_together_due_to_a_limitation
这似乎是不可能的。
https://stackoverflow.com/questions/10227614
复制相似问题