Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:48:21+00:00 2026-05-28T17:48:21+00:00

In my project I created a transparent and frameless QMainWindow, then created QmlApplicationViewer. I

  • 0

In my project I created a transparent and frameless QMainWindow, then created QmlApplicationViewer. I need to be able to drag and resize the window.
How can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:48:23+00:00Added an answer on May 28, 2026 at 5:48 pm

    This app is a small variation of the one presented here to deal with transparent windows in QML applications:

    win.cpp:

    #include <QApplication>
    #include <QDeclarativeView>
    #include <QMainWindow>
    #include <QDeclarativeContext>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QMainWindow window;
    
        QDeclarativeView* v = new QDeclarativeView;
        window.setCentralWidget(v);
    
        v->setSource(QUrl::fromLocalFile(("draw_rectangles.qml")));   
    
        // expose window object to QML
        v->rootContext()->setContextProperty("mainwindow",&window);
    
        window.setStyleSheet("background:transparent;");
        window.setAttribute(Qt::WA_TranslucentBackground);
        window.setWindowFlags(Qt::FramelessWindowHint);
        window.show();
    
        app.exec();
    }
    

    win.pro:

    TEMPLATE += app
    QT += gui declarative
    SOURCES += win.cpp
    

    draw_rectangles.qml:

    import Qt 4.7
    
    Item {
         Rectangle {
             opacity: 0.5
             color: "red"
             width: 100; height: 100
    
             MouseArea {
                anchors.fill: parent
                onPressed: {
                    mainwindow.size.width = 200;
                    mainwindow.size.height = 500;
                }
             }
    
             Rectangle {
                 color: "blue"
                 x: 50; y: 50; width: 100; height: 100
    
                MouseArea {
                    id: mouseRegion
                    anchors.fill: parent;
                    property variant clickPos: "1,1"
    
                    onPressed: {
                        clickPos  = Qt.point(mouse.x,mouse.y)
                    }
    
                    onPositionChanged: {
                        var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
                        mainwindow.pos = Qt.point(mainwindow.pos.x+delta.x,
                                          mainwindow.pos.y+delta.y)
                    }
                }
             }
         }
     }
    

    Even though you are not interested in transparency, this app shows how to expose QMainWindow to QML. This allows the QML application to make changes in the main window.

    Click on the blue rectangle to drag the window around, and click on the red rectangle to resize the window using hardcoded values in the qml. Of course, as the window is transparent you won’t have the visual feedback of a regular opaque application when you resize it. But the resize operation works, though. Enjoy!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a new web application project in Visual Studio 2008, and then copied
I have project created in eclipse. Can you please guide me how can i
We have an ADP project created several years ago using Access 2000. This project
I just installed VS 2010 RC and now my MVC 2 project created in
If a VS2008 project is created initially with a web app project, and class
In my project I created a webservice client with Spring Web Services (2.0.4.RELEASE). The
Just for fun I created a project that created about 5 GB of memory
I am using VS 2008. When I opened a c# project file created by
Please help me solve my big problem. in my on-line shopping project i created
info: xcode 4.3.2, iOS5, using storyboard. Created project from xcode's Tabbed Application template. Did:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.