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. Placing QQuickView in a QMainWindow?
Forum Update on Monday, May 27th 2025

Placing QQuickView in a QMainWindow?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.1k 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.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    Hi,

    How can I place a QQuickView in a main window? I have tried this code but it doesn't work (it works for QDeclarativeView though)

    @hud::hud(QWidget *parent) :
    QMainWindow(parent)
    {
    this->setAttribute( Qt::WA_TranslucentBackground );
    //this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    this->setStyleSheet(
    "background-color:rgba(255,255,255,0.0);"
    );

    QQuickView *hudView = new QQuickView;
    hudView->setSource(QUrl::fromLocalFile("/Users/nick/Desktop/Development/QT dev/hud_v4/hud.qml"));
    hudView->setStyleSheet(
                    "background-color:rgba(255,255,255,0.0);"
                    );
    
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(hudView);
    this->setLayout(layout);
    
    setCentralWidget(hudView);
    

    }
    @

    Obviously this code doesn't work. What is the proper way to add the QQuickView to the QMainWindow?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      QQuickView a subclass of QWindow, but QWidget is needed when you want to add it to QMainWindow.

      So QWidget::createWindowContainer() will be useful for you.

      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