Results 1 to 3 of 3

Thread: Mouse Area question

  1. #1
    Join Date
    Dec 2014
    Posts
    29
    Thanks
    12
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Mouse Area question

    Hello, I want to "hide" control area when mouse is not there, but if I do it this way:

    Qt Code:
    1. import QtQuick 2.3
    2. import QtQuick.Window 2.2
    3. import QtMultimedia 5.0
    4. import QtQuick.Controls 1.4
    5. import QtQuick.Layouts 1.0
    6. import QtQuick.Dialogs 1.2
    7. import QtQuick.Extras 1.4
    8.  
    9. Window {
    10. id: mainArea
    11. visible: true
    12. minimumWidth: 1200
    13. minimumHeight: 720
    14. color: "white"
    15.  
    16. Rectangle {
    17. id: controlArea
    18. anchors.bottom: parent.bottom
    19. anchors.horizontalCenter: parent.horizontalCenter
    20. anchors.bottomMargin: 0
    21. width: 400
    22. height: 50
    23. opacity: 0.40
    24. color: "lightgray"
    25. radius: 10
    26.  
    27. RowLayout {
    28. anchors.centerIn: parent
    29. ToolButton {
    30. text: "test"
    31. }
    32.  
    33. }
    34. MouseArea {
    35. z: 100
    36. anchors.fill: parent
    37. hoverEnabled:true
    38. onEntered: {
    39. console.log("ENTERED toolbar mousearea");
    40. controlArea.opacity = 0.40
    41. }
    42. onExited: {
    43. console.log("EXITED toolbar mousearea");
    44. controlArea.opacity = 0.0
    45. }
    46.  
    47. }
    48.  
    49. }
    50.  
    51. }
    To copy to clipboard, switch view to plain text mode 

    button doesn't work, so I tried adjusting it with this:

    Qt Code:
    1. import QtQuick 2.3
    2. import QtQuick.Window 2.2
    3. import QtMultimedia 5.0
    4. import QtQuick.Controls 1.4
    5. import QtQuick.Layouts 1.0
    6. import QtQuick.Dialogs 1.2
    7. import QtQuick.Extras 1.4
    8.  
    9. Window {
    10. id: mainArea
    11. visible: true
    12. minimumWidth: 1200
    13. minimumHeight: 720
    14. color: "white"
    15.  
    16. Rectangle {
    17. id: controlArea
    18. anchors.bottom: parent.bottom
    19. anchors.horizontalCenter: parent.horizontalCenter
    20. anchors.bottomMargin: 0
    21. width: 400
    22. height: 50
    23. opacity: 0.40
    24. color: "lightgray"
    25. radius: 10
    26.  
    27.  
    28. RowLayout {
    29. anchors.centerIn: parent
    30. ToolButton {
    31. text: "test"
    32. }
    33. z: 99
    34. MouseArea {
    35. anchors.fill: parent
    36. acceptedButtons: Qt.RightButton
    37. onClicked: {
    38. console.log("right button was clicked");
    39. }
    40. }
    41. }
    42. MouseArea {
    43. z: 100
    44. anchors.fill: parent
    45. hoverEnabled:true
    46. onEntered: {
    47. console.log("ENTERED toolbar mousearea");
    48. controlArea.opacity = 0.40
    49. }
    50. onExited: {
    51. console.log("EXITED toolbar mousearea");
    52. controlArea.opacity = 0.0
    53. }
    54.  
    55. }
    56.  
    57. }
    58.  
    59. }
    To copy to clipboard, switch view to plain text mode 

    now button works but I'm not sure this is correct way of doing what I wanted, and this "controlArea.opacity" is not supported by Qt Quick designer.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Area question

    Quote Originally Posted by vuletic View Post
    button doesn't work, so I tried adjusting it with this:
    Two suggestions:
    - put the mouse area "under" the RowLayout, e.g. by making it the first child of controlArea
    - bind the opacity to the mouse area's containsMouse property instead of signal handling

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    vuletic (4th October 2015)

  4. #3
    Join Date
    Dec 2014
    Posts
    29
    Thanks
    12
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Area question

    That's all I needed, thanks

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 07:16
  2. How to exceed mouse area of Qpushbutton
    By vidya.p in forum Newbie
    Replies: 2
    Last Post: 26th November 2011, 04:12
  3. How to add mouse area at a desired frame
    By athulms in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2011, 17:26
  4. Set Mouse Area ?
    By mrfreeman in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2011, 08:18
  5. select QPixmap area with mouse
    By tommy in forum Newbie
    Replies: 2
    Last Post: 16th November 2007, 18:15

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.