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. Overlay Issue between QWebView and QOpenGL widget
Qt 6.11 is out! See what's new in the release blog

Overlay Issue between QWebView and QOpenGL widget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 652 Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I am trying to develop an application where I am loading an html page on QWebView and drawing a QOpenGLWidget on top of that to display few important graphic information.
    Facing few overlay issues to achieve this.

    The set up looks good when I use "setAttribute( Qt::WA_AlwaysStackOnTop)" attribute. But the problem starts when I use dropdowns or popovers from my html page on top of the widget.
    When I use html elements like drop-down(for example to select from a list of tools available) both the graphic item and the drop-down appear simultaneously(assuing WA_AlwaysStackOnTop is set).
    My requirement is to have the components like drop-down opaque so that whenever I have a drop-down on my html page, the graphics on the widget is not visible only for that particular region.

    Tried out different options, seems like nothing works.

    Given below is a brief account of what I am doing

    MainWindow::MainWindow(QWidget parent) :
    QMainWindow(parent)
    {
    QDesktopWidget
    desktopWidget = QApplication::desktop();
    QRect screenRect = desktopWidget->screenGeometry();

    MAX_y = screenRect.height();
    MAX_x = screenRect.width();
    
    this->setFixedSize(MAX_x , MAX_y);
    wv = new QView(this);
    wv->setGeometry(0,0,this->width(), this->height());
    
    wv->loadPage(QUrl::fromLocalFile("/../.../xxx.html"));
    

    }

    MainWindow::~MainWindow()
    {
    }

    QView::QView(QWidget *parent) :
    QWebView(parent)
    {
    QObject::connect(this, SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded(bool)));
    viewer = new Viewer(parent, queue);
    QPalette palette = this->palette();
    palette.setBrush(QPalette::Base, Qt::transparent);
    this->page()->setPalette(palette);
    this->setAttribute(Qt::WA_OpaquePaintEvent, false);
    }

    QView::~QView() {
    }

    void QView::loadPage(QUrl url) {
    this->load(url);
    QObject::connect(this->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
    }

    void QView::pageLoaded(bool isOK) {

    this->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    this->page()->mainFrame()->evaluateJavaScript("setup()");
    
    // For Testing purpose only. setViewerPosition can be triggered from JavaScript layer.
    setViewerPosition(40,360,700,600);
    

    }

    void QView::populateJavaScriptWindowObject() {
    this->page()->mainFrame()->addToJavaScriptWindowObject("jsbridge", this);
    }

    void QView::setViewerPosition(int x, int y, int w, int h) {
    viewer->move(x, y);
    viewer->resize(w, h);
    viewer->show();
    viewer->refresh();
    }

    Viewer::Viewer(QWidget parent) :
    QOpenGLWidget(parent)
    {
    QDesktopWidget
    desktopWidget = QApplication::desktop();
    m_ScreenRect = desktopWidget->screenGeometry();
    MAX_Y = m_ScreenRect.height();
    MAX_X = m_ScreenRect.width();
    layout = new ViewerLayout(2, 4, MAX_X/2, MAX_Y/2);
    setAttribute( Qt::WA_AlwaysStackOnTop);
    }

    Viewer::~Viewer()
    {
    delete layout;
    }

    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