Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to overlay a transparent Widget on the contents of DX rendering?
Forum Updated to NodeBB v4.3 + New Features

How to overlay a transparent Widget on the contents of DX rendering?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 438 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pegeset
    wrote on last edited by pegeset
    #1

    Hey guys
    I have a very difficult problem here, and I hope to get your help.

    I created a QWidget and passed the handle to the DX to draw a 3D scenario for QWidget. At the same time I want to put a QWidget on this QWidget as a mask, which I need to set to transparent / translucent, but when I set this mask to transparent / translucent, its background does not show the content of DX, but black. I looked up the relevant information, saying that the way QWidget was drawn was different from that of DX, and that QWidget could not get the content of the DX drawing, so it was not transparent to display the content of the DX.

    Is there anyone who can help solve this problem? Thanks very much。

    P.S below is some code snippets:

    QtIFCCtrl::QtIFCCtrl(QWidget *parent)
    : QWidget(parent), m_showFaces(true), m_showWireFrame(true), m_showLines(true), m_showPoints(true), m_showSkyBox(false)
    , m_iZoomMouseX(0), m_iZoomMouseY(0), m_initialized(false), m_DirectXStatus(0)
    , m_fZoomScale(0.02)
    , m_kCameraMoveAmt(0.002f), m_kMaxAngle(89.99f)
    , m_CubePosition(0, 0, 0), m_vectorOrigin(0,0,0)
    , m_noVertices(0), m_dbsize(0)
    , m_pVerticesDeviceBuffer(nullptr), m_pIndicesDeviceBuffer(nullptr)
    , m_facesToDraw(false), m_vertexOffset(0), m_indexOffsetForFaces(0), m_noPrimitivesForFaces(0)
    , m_wireFrameToDraw(false), m_linesToDraw(false), m_pointsToDraw(false)
    , m_indexOffsetForWireFrame(0), m_noPrimitivesForWireFrame(0), m_indexOffsetForLines(0)
    , m_noPrimitivesForLines(0), m_indexOffsetForPoints(0), m_noPrimitivesForPoints(0)
    {
    for (int i = 0; i < 6; i++)
    {
    m_pTextureSkyBox[i] = nullptr;
    }

    m_testLight.Diffuse.r = 0.2f;
    m_testLight.Diffuse.g = 0.2f;
    m_testLight.Diffuse.b = 0.2f;
    m_testLight.Diffuse.a = 1.0f;
    m_testLight.Specular.r = 0.2f;//0.3f;
    m_testLight.Specular.g = 0.2f;//0.3f;
    m_testLight.Specular.b = 0.2f;//0.3f;
    m_testLight.Specular.a = 1.0f;//0.5f;
    m_testLight.Ambient.r = 0.2f;//0.7f;
    m_testLight.Ambient.g = 0.2f;//0.7f;
    m_testLight.Ambient.b = 0.2f;//0.7f;
    m_testLight.Ambient.a = 1.0f;
    

    // ui.setupUi(this);
    setAttribute(Qt::WA_PaintOnScreen, true);
    // setAttribute(Qt::WA_NativeWindow);

    InitExpreeSchema();
    
    if (!m_initialized) {
    	m_pD3D = NULL;
    	m_pd3dDevice = NULL;
    	m_pVB = NULL;
    	m_pIB = NULL;
    	m_pTexture = NULL;
    	m_pLine = NULL;
    	m_pVertexBufferSkyBox = NULL;
    	m_pIBSyeBox = NULL;
    
    	m_hwndRenderWindow = (HWND)(winId());
    	
    	m_iWidth = width();
    	m_iHeight = height();
    

    // CRect rc(rect().left(), rect().top(), rect().width(), rect().height());
    InitializeDevice(NULL);
    InitializeDeviceBuffer();

    	m_initialized = true;
    
    	Render(false);
    }
    

    }

    Make the mask code:

    IFCVQT::IFCVQT(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);

    ifctrl = new QtIFCCtrl(this);
    
    QWidget* qw = new QWidget(this);
    qw->setStyleSheet(QString("background-color:rgba(255,0,0,15)"));
    //qw->setAttribute(Qt::WA_NoBackground);
    qw->setGeometry(100, 100, 300, 300);
    

    // ifcWidget = new QtIFCWidget(this);
    setCentralWidget(ifctrl);

    //ifctrl->setStyleSheet(QString("background-color:rgba(255,0,0,0)"));
    
    
    this->connect(ui.actionpoint, SIGNAL(triggered(bool)), this, SLOT(actionPoint()));
    this->connect(ui.actionline, SIGNAL(triggered(bool)), this, SLOT(actionLine()));
    this->connect(ui.actionframe, SIGNAL(triggered(bool)), this, SLOT(actionFrame()));
    this->connect(ui.actionface, SIGNAL(triggered(bool)), this, SLOT(actionFace()));
    this->connect(ui.actionside, SIGNAL(triggered(bool)), this, SLOT(actionSide()));
    this->connect(ui.actionLoadFile, SIGNAL(triggered(bool)), this, SLOT(actionLoadFile()));
    this->connect(ui.actionLoadFile2, SIGNAL(triggered(bool)), this, SLOT(actionLoadFile2()));
    this->connect(ui.actionfront, SIGNAL(triggered(bool)), this, SLOT(actionFront()));
    this->connect(ui.actionfloor, SIGNAL(triggered(bool)), this, SLOT(actionFloor()));
    this->connect(ui.actionsystem, SIGNAL(triggered(bool)), this, SLOT(actionSystem()));
    this->connect(ui.actionunref, SIGNAL(triggered(bool)), this, SLOT(actionUnref()));
    this->connect(ui.actiontransparent, SIGNAL(triggered(bool)), this, SLOT(actionTransparent()));
    this->connect(ui.actionshowOnly, SIGNAL(triggered(bool)), this, SLOT(actionshowOnly()));
    this->connect(ui.actionhide, SIGNAL(triggered(bool)), this, SLOT(actionhide()));
    this->connect(ui.actionshow, SIGNAL(triggered(bool)), this, SLOT(actionshow()));
    this->connect(ui.actionCleanTransparent, SIGNAL(triggered(bool)), this, SLOT(actionCleanTransparent()));
    this->connect(ui.actionshowAll, SIGNAL(triggered(bool)), this, SLOT(actionshowAll()));
    this->connect(ui.actionLight, SIGNAL(triggered(bool)), this, SLOT(actionLight()));
    this->connect(ui.actionTree, SIGNAL(triggered(bool)), this, SLOT(actionTree()));
    this->connect(ui.actionResetAll, SIGNAL(triggered(bool)), this, SLOT(actionResetAll()));
    
    this->connect(ifctrl, SIGNAL(ifcItemSelect(QString)), this, SLOT(ifcItemSelect(QString)));
    

    }

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved