调用qt方法


# -*- coding: utf-8 -*-
# create tools menu when startup
import os
from functools import partial

from Qt import QtWidgets
import unreal


from menu_creator.dcc import unreal_creator


def create_menu():
    data = {}
    creator = unreal_creator.UnrealMenuCreator(data)
    creator.create()


def __QtAppTick__(delta_seconds):
    QtWidgets.QApplication.sendPostedEvents()


if __name__ == '__main__':
    create_menu()
    unreal_app = QtWidgets.QApplication.instance()
    if not unreal_app:
        unreal_app = QtWidgets.QApplication([])
        tick_handle = unreal.register_slate_post_tick_callback(__QtAppTick__)
        __QtAppQuit__ = partial(
            unreal.unregister_slate_post_tick_callback, tick_handle)
        unreal_app.aboutToQuit.connect(__QtAppQuit__)

def main():
    main_window = ShowWindow()
    unreal.parent_external_window_to_slate(int(main_window.winId()))
    main_window.show()
    return main_window


win = main()
# 这里一定要用个变量,不然就秒退啦
# 这是因为你的show()函数里的Qt实例是个局部变量,函数运行完了这个变量就销毁了,GUI就因此秒没

评论
  目录