本文整理汇总了C++中QWindow::create方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::create方法的具体用法?C++ QWindow::create怎么用?C++ QWindow::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWindow
的用法示例。
在下文中一共展示了QWindow::create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static QSurface *createSurface(int surfaceClass)
{
if (surfaceClass == int(QSurface::Window)) {
QWindow *window = new QWindow;
window->setSurfaceType(QWindow::OpenGLSurface);
window->setGeometry(0, 0, 10, 10);
window->create();
return window;
} else if (surfaceClass == int(QSurface::Offscreen)) {
// Create a window and get the format from that. For example, if an EGL
// implementation provides 565 and 888 configs for PBUFFER_BIT but only
// 888 for WINDOW_BIT, we may end up with a pbuffer surface that is
// incompatible with the context since it could choose the 565 while the
// window and the context uses a config with 888.
static QSurfaceFormat format;
if (format.redBufferSize() == -1) {
QWindow *window = new QWindow;
window->setSurfaceType(QWindow::OpenGLSurface);
window->setGeometry(0, 0, 10, 10);
window->create();
format = window->format();
delete window;
}
QOffscreenSurface *offscreenSurface = new QOffscreenSurface;
offscreenSurface->setFormat(format);
offscreenSurface->create();
return offscreenSurface;
}
return 0;
}
示例2: dumpGlInfo
void dumpGlInfo(QTextStream &str, bool listExtensions)
{
QOpenGLContext context;
if (context.create()) {
# ifdef QT_OPENGL_DYNAMIC
str << "Dynamic GL ";
# endif
switch (context.openGLModuleType()) {
case QOpenGLContext::LibGL:
str << "LibGL";
break;
case QOpenGLContext::LibGLES:
str << "LibGLES";
break;
}
QWindow window;
window.setSurfaceType(QSurface::OpenGLSurface);
window.create();
context.makeCurrent(&window);
QOpenGLFunctions functions(&context);
str << " Vendor: " << reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR))
<< "\nRenderer: " << reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER))
<< "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION))
<< "\nShading language: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION))
<< "\nFormat: " << context.format();
if (listExtensions) {
QList<QByteArray> extensionList = context.extensions().toList();
std::sort(extensionList.begin(), extensionList.end());
str << " \nFound " << extensionList.size() << " extensions:\n";
foreach (const QByteArray &extension, extensionList)
str << " " << extension << '\n';
}
} else {
示例3: initialize
void KisOpenGL::initialize()
{
if (initialized) return;
setDefaultFormat();
// we need a QSurface active to get our GL functions from the context
QWindow surface;
surface.setSurfaceType( QSurface::OpenGLSurface );
surface.create();
QOpenGLContext context;
context.create();
context.makeCurrent( &surface );
QOpenGLFunctions *funcs = context.functions();
funcs->initializeOpenGLFunctions();
qDebug() << "OpenGL Info";
qDebug() << " Vendor: " << reinterpret_cast<const char *>(funcs->glGetString(GL_VENDOR));
qDebug() << " Renderer: " << reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER));
qDebug() << " Version: " << reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION));
qDebug() << " Shading language: " << reinterpret_cast<const char *>(funcs->glGetString(GL_SHADING_LANGUAGE_VERSION));
qDebug() << " Requested format: " << QSurfaceFormat::defaultFormat();
qDebug() << " Current format: " << context.format();
glMajorVersion = context.format().majorVersion();
glMinorVersion = context.format().minorVersion();
supportsDeprecatedFunctions = (context.format().options() & QSurfaceFormat::DeprecatedFunctions);
initialized = true;
}
示例4: fboHandleNulledAfterContextDestroyed
void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
{
QWindow window;
window.setSurfaceType(QWindow::OpenGLSurface);
window.setGeometry(0, 0, 10, 10);
window.create();
QOpenGLFramebufferObject *fbo = 0;
{
QOpenGLContext ctx;
ctx.create();
ctx.makeCurrent(&window);
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
fbo = new QOpenGLFramebufferObject(128, 128);
QVERIFY(fbo->handle() != 0);
}
QCOMPARE(fbo->handle(), 0U);
}
示例5: openGlContext
QString openGlContext()
{
QString result;
QTextStream str(&result);
QOpenGLContext context;
if (context.create()) {
# ifdef QT_OPENGL_DYNAMIC
str << "Dynamic GL ";
# endif
switch (context.openGLModuleType()) {
case QOpenGLContext::LibGL:
str << "LibGL";
break;
case QOpenGLContext::LibGLES:
str << "LibGLES";
break;
}
QWindow window;
if (QGuiApplication::platformName() == QLatin1String("greenisland"))
window.setFlags(Qt::Desktop);
window.setSurfaceType(QSurface::OpenGLSurface);
//window.setScreen(QGuiApplication::primaryScreen());
window.create();
if (context.makeCurrent(&window)) {
QOpenGLFunctions functions(&context);
str << " Vendor: " << reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR))
<< "\nRenderer: " << reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER))
<< "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION))
<< "\nGLSL version: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION))
<< "\nFormat: " << context.format();
QList<QByteArray> extensionList = context.extensions().toList();
std::sort(extensionList.begin(), extensionList.end());
QByteArray extensions = extensionList.join(' ');
str << " \nFound " << extensionList.size() << " extensions:\n";
str << wordWrap(extensions, 78);
context.doneCurrent();
}
window.destroy();
} else {
str << "Unable to create an Open GL context.\n";
}
return result;
}
示例6: if
static QSurface *createSurface(int surfaceClass)
{
if (surfaceClass == int(QSurface::Window)) {
QWindow *window = new QWindow;
window->setSurfaceType(QWindow::OpenGLSurface);
window->setGeometry(0, 0, 10, 10);
window->create();
return window;
} else if (surfaceClass == int(QSurface::Offscreen)) {
QOffscreenSurface *offscreenSurface = new QOffscreenSurface;
offscreenSurface->create();
return offscreenSurface;
}
return 0;
}
示例7: aboutToBeDestroyed
void tst_QOpenGL::aboutToBeDestroyed()
{
QWindow window;
window.setSurfaceType(QWindow::OpenGLSurface);
window.setGeometry(0, 0, 128, 128);
window.create();
QOpenGLContext *context = new QOpenGLContext;
QSignalSpy spy(context, SIGNAL(aboutToBeDestroyed()));
context->create();
context->makeCurrent(&window);
QCOMPARE(spy.size(), 0);
delete context;
QCOMPARE(spy.size(), 1);
}
示例8: request
/**
* Request the video to avoid the conflicts
**/
bool VideoWidget::request( struct vout_window_t *p_wnd )
{
if( stable )
{
msg_Dbg( p_intf, "embedded video already in use" );
return false;
}
assert( !p_window );
/* The owner of the video window needs a stable handle (WinId). Reparenting
* in Qt4-X11 changes the WinId of the widget, so we need to create another
* dummy widget that stays within the reparentable widget. */
stable = new QWidget();
QPalette plt = palette();
plt.setColor( QPalette::Window, Qt::black );
stable->setPalette( plt );
stable->setAutoFillBackground(true);
/* Force the widget to be native so that it gets a winId() */
stable->setAttribute( Qt::WA_NativeWindow, true );
/* Indicates that the widget wants to draw directly onto the screen.
Widgets with this attribute set do not participate in composition
management */
/* This is currently disabled on X11 as it does not seem to improve
* performance, but causes the video widget to be transparent... */
#if !defined (QT5_HAS_X11)
stable->setAttribute( Qt::WA_PaintOnScreen, true );
#else
stable->setMouseTracking( true );
setMouseTracking( true );
#endif
layout->addWidget( stable );
sync();
p_window = p_wnd;
p_wnd->type = p_intf->p_sys->voutWindowType;
switch( p_wnd->type )
{
case VOUT_WINDOW_TYPE_XID:
p_wnd->handle.xid = stable->winId();
p_wnd->display.x11 = NULL;
break;
case VOUT_WINDOW_TYPE_HWND:
p_wnd->handle.hwnd = (void *)stable->winId();
break;
case VOUT_WINDOW_TYPE_NSOBJECT:
p_wnd->handle.nsobject = (void *)stable->winId();
break;
#ifdef QT5_HAS_WAYLAND
case VOUT_WINDOW_TYPE_WAYLAND:
{
QWindow *window = stable->windowHandle();
assert(window != NULL);
window->create();
QPlatformNativeInterface *qni = qApp->platformNativeInterface();
assert(qni != NULL);
p_wnd->handle.wl = static_cast<wl_surface*>(
qni->nativeResourceForWindow(QByteArrayLiteral("surface"),
window));
p_wnd->display.wl = static_cast<wl_display*>(
qni->nativeResourceForIntegration(QByteArrayLiteral("wl_display")));
break;
}
#endif
default:
vlc_assert_unreachable();
}
return true;
}
示例9: fbo
void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
QSKIP("QTBUG-22617");
#endif
QWindow window;
window.setSurfaceType(QWindow::OpenGLSurface);
window.setGeometry(0, 0, 128, 128);
window.create();
QOpenGLContext ctx;
ctx.create();
ctx.makeCurrent(&window);
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
QOpenGLFramebufferObject fbo(128, 128);
fbo.bind();
QOpenGLPaintDevice device(128, 128);
// QTBUG-15621 is only a problem when qreal is double, but do the test anyway.
qreal delta = sizeof(qreal) == sizeof(float) ? 1e-4 : 1e-8;
QVERIFY(128 != 128 + delta);
QPainterPath path;
path.moveTo(16 + delta, 16);
path.moveTo(16, 16);
path.lineTo(16 + delta, 16); // Short lines to check for division by zero.
path.lineTo(112 - delta, 16);
path.lineTo(112, 16);
path.quadTo(112, 16, 112, 16 + delta);
path.quadTo(112, 64, 112, 112 - delta);
path.quadTo(112, 112, 112, 112);
path.cubicTo(112, 112, 112, 112, 112 - delta, 112);
path.cubicTo(80, 112, 48, 112, 16 + delta, 112);
path.cubicTo(16 + delta, 112, 16 + delta, 112, 16, 112);
path.closeSubpath();
QPen pen(Qt::red, 28, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
QPainter p(&device);
p.fillRect(QRect(0, 0, 128, 128), Qt::blue);
p.strokePath(path, pen);
p.end();
QImage image = fbo.toImage().convertToFormat(QImage::Format_RGB32);
const QRgb red = 0xffff0000;
const QRgb blue = 0xff0000ff;
QCOMPARE(image.pixel(8, 8), red);
QCOMPARE(image.pixel(119, 8), red);
QCOMPARE(image.pixel(8, 119), red);
QCOMPARE(image.pixel(119, 119), red);
QCOMPARE(image.pixel(0, 0), blue);
QCOMPARE(image.pixel(127, 0), blue);
QCOMPARE(image.pixel(0, 127), blue);
QCOMPARE(image.pixel(127, 127), blue);
QCOMPARE(image.pixel(32, 32), blue);
QCOMPARE(image.pixel(95, 32), blue);
QCOMPARE(image.pixel(32, 95), blue);
QCOMPARE(image.pixel(95, 95), blue);
}
示例10: create_sys
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_Q(QWidget);
Q_UNUSED(window);
Q_UNUSED(initializeWindow);
Q_UNUSED(destroyOldWindow);
Qt::WindowFlags flags = data.window_flags;
if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
return; // we only care about real toplevels
QWindow *win = topData()->window;
// topData() ensures the extra is created but does not ensure 'window' is non-null
// in case the extra was already valid.
if (!win) {
createTLSysExtra();
win = topData()->window;
}
win->setFlags(data.window_flags);
fixPosIncludesFrame();
if (q->testAttribute(Qt::WA_Moved))
win->setGeometry(q->geometry());
else
win->resize(q->size());
win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0));
if (q->testAttribute(Qt::WA_TranslucentBackground)) {
QSurfaceFormat format;
format.setAlphaBufferSize(8);
win->setFormat(format);
}
if (QWidget *nativeParent = q->nativeParentWidget()) {
if (nativeParent->windowHandle()) {
if (flags & Qt::Window) {
win->setTransientParent(nativeParent->windowHandle());
win->setParent(0);
} else {
win->setTransientParent(0);
win->setParent(nativeParent->windowHandle());
}
}
}
qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive;
win->create();
// Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing.
if ((flags & Qt::Desktop) == Qt::Window)
win->handle()->setFrameStrutEventsEnabled(true);
data.window_flags = win->flags();
QBackingStore *store = q->backingStore();
if (!store) {
if (win && q->windowType() != Qt::Desktop)
q->setBackingStore(new QBackingStore(win));
else
q->setAttribute(Qt::WA_PaintOnScreen, true);
}
setWindowModified_helper();
setWinId(win->winId());
// Check children and create windows for them if necessary
q_createNativeChildrenAndSetParent(q);
if (extra && !extra->mask.isEmpty())
setMask_sys(extra->mask);
// If widget is already shown, set window visible, too
if (q->isVisible())
win->setVisible(true);
}
示例11: main
//.........这里部分代码省略.........
pcmd.setCheckersBackground(checkers_background);
QWidget *activeWidget = 0;
if (interactive) {
runInteractive();
if (!files.isEmpty())
interactive_widget->load(files.at(0));
} else if (files.isEmpty()) {
printHelp();
return 0;
} else {
for (int j=0; j<files.size(); ++j) {
const QString &fileName = files.at(j);
QStringList content;
QFile file(fileName);
QFileInfo fileinfo(file);
if (file.open(QIODevice::ReadOnly)) {
QTextStream textFile(&file);
QString script = textFile.readAll();
content = script.split("\n", QString::SkipEmptyParts);
} else {
printf("failed to read file: '%s'\n", qPrintable(fileinfo.absoluteFilePath()));
continue;
}
pcmd.setContents(content);
if (show_cmp) {
QString pmFile = QString(files.at(j)).replace(".qps", "_qps") + ".png";
qDebug() << pmFile << QFileInfo(pmFile).exists();
QPixmap pixmap(pmFile);
if (!pixmap.isNull()) {
QLabel *label = createLabel();
label->setWindowTitle("VERIFY: " + pmFile);
label->setPixmap(pixmap);
label->show();
}
}
switch (type) {
case WidgetType:
{
OnScreenWidget<QWidget> *qWidget =
new OnScreenWidget<QWidget>(files.at(j));
qWidget->setVerboseMode(verboseMode);
qWidget->setType(type);
qWidget->setCheckersBackground(checkers_background);
qWidget->m_commands = content;
qWidget->resize(width, height);
qWidget->show();
activeWidget = qWidget;
break;
}
case ImageWidgetType:
{
OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>(files.at(j));
qWidget->setVerboseMode(verboseMode);
qWidget->setType(type);
qWidget->setCheckersBackground(checkers_background);
qWidget->m_commands = content;
qWidget->resize(width, height);
qWidget->show();
activeWidget = qWidget;