Results 1 to 5 of 5

Thread: Fully transparent, dragable window

  1. #1
    Join Date
    Feb 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Fully transparent, dragable window

    Hello,

    I want to create an invisible, frameless, dragable window with two visible buttons.
    Frameless an invisible works fine when I use:
    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint);
    2. setAttribute(Qt::WA_TranslucentBackground);
    To copy to clipboard, switch view to plain text mode 
    Added Buttons are visible.

    But if I click around the buttons, where the invisible mainWindow should be, the click goes right through to whatever application there behind is.
    I reimplemented the mouseMoveEvent and mousePressEvent, to drag the main window. When the window is visible this works great:
    Qt Code:
    1. void MainWindow::mouseMoveEvent(QMouseEvent *event)
    2. {
    3. move(event->globalX()-m_nMouseClick_X_Coordinate,event->globalY()-m_nMouseClick_Y_Coordinate);
    4. }
    5.  
    6. void MainWindow::mousePressEvent(QMouseEvent *event)
    7. {
    8. m_nMouseClick_X_Coordinate = event->x();
    9. m_nMouseClick_Y_Coordinate = event->y();
    10. qDebug() << "mouse press event" << endl;
    11. }
    To copy to clipboard, switch view to plain text mode 

    If it is invisible nothing happens.

    How can I make the invisible area of the mainwindow clickable, so i can drag it?

    Regards

    Redar

    Edit: This program should run on windows

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Fully transparent, dragable window

    I think your requirements are contradictory. You want to be able to click and drag the invisible window but at the same time you want the click to go through the underlying app. So which is it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Fully transparent, dragable window

    Quote Originally Posted by wysota View Post
    I think your requirements are contradictory. You want to be able to click and drag the invisible window but at the same time you want the click to go through the underlying app. So which is it?
    Sorry, I thought it was clear.

    I want the invisible window click and dragable.
    I don't want that the click goes through.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Fully transparent, dragable window

    You can make your widget grab the mouse. Just remember to release it at some point.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Fully transparent, dragable window

    I just tried grabMouse.
    Problem is that grabMouse works if the widget is visible, but setAttribute(Qt::WA_TranslucentBackground) sets the widget invisible, so grabMouse has no effect.

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11
  2. transparent window with X11 and Qt4.2.3
    By jrodway in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2012, 13:27
  3. Transparent Window
    By Beena in forum Qt Programming
    Replies: 0
    Last Post: 12th November 2010, 11:22
  4. Transparent Window in qt4.5.1
    By raghvendramisra in forum Qt Programming
    Replies: 6
    Last Post: 25th October 2009, 02:19
  5. QWidget setMask fully transparent.
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 6th August 2009, 13:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.