首页 > 学院 > 开发设计 > 正文

Qt mac sdl窗口指针

2019-11-06 06:33:14
字体:
来源:转载
供稿:网友
QWidget *t_newWidget = new QWidget(NULL);
t_newWidget->resize(300,400);
t_newWidget->show();
NSView * view = (NSView *) t_newWidget->winId();
NSWindow * nsWin = [view window];
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindowFrom((void*)nsWin);
            //SDL_CreateWindow("test windows", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,500, 200,SDL_WINDOW_SHOWN);;
            //SDL_CreateWindowFrom((void*)t_newWidget->winId());
SDL_Renderer* render = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
SDL_SetRenderDrawColor(render, 255, 0, 0, 255);
SDL_RenderFillRect(render, NULL);
SDL_RenderPResent(render);
pro中添加:
LIBS += -framework Foundation
.mm中添加:
#import <cocoa/cocoa.h>
记得文件后缀要由:.cpp 改为 .mm

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表