Results 1 to 3 of 3

Thread: How to change Gradient color of button with Enter Key Pressed Event ? :(:(

  1. #1
    Join Date
    Nov 2011
    Posts
    17
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to change Gradient color of button with Enter Key Pressed Event ? :(:(

    Hi everyone,

    I have a problem that when i try to design my GUI,
    i use one Button.qml file to design my Button. And this button use Gradient to describe default color.

    But when i try to use Keyboard event, i cannot to use Enter keyboard event to trigger this default color.

    the console pop up a message like this : Cannot assign null to QColor

    Can somebody help me debug this error ?

    Thank u so much

  2. #2
    Join Date
    Nov 2011
    Posts
    17
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: How to change Gradient color of button with Enter Key Pressed Event ? :(:(

    Qt Code:
    1. import QtQuick 1.0
    2.  
    3. Rectangle {
    4. id: container
    5.  
    6. property variant text
    7. signal clicked
    8.  
    9. height: text.height + 25; width: text.width + 20;
    10. border.width: 7
    11. radius: 100
    12. smooth: true
    13.  
    14. gradient: Gradient {
    15. GradientStop {
    16. position: 0.0
    17. color: !mouseArea.pressed ? activePalette.light : activePalette.button //this
    18. }
    19. GradientStop {
    20. position: 1.0
    21. color: !mouseArea.pressed ? activePalette.button : activePalette.dark //this
    22. }
    23. }
    24.  
    25.  
    26.  
    27. SystemPalette { id: activePalette }
    28. Text {
    29. id: text
    30. x: 0
    31. y: 0
    32. text: container.text
    33. anchors.verticalCenter: parent.verticalCenter
    34. anchors.horizontalCenter: parent.horizontalCenter
    35. wrapMode: Text.WordWrap
    36. opacity: 1
    37. smooth: true
    38. horizontalAlignment: Text.AlignRight
    39. verticalAlignment: Text.AlignVCenter
    40. style: Text.Outline
    41. font.bold: true
    42. font.pointSize: 35
    43. }
    44. MouseArea {
    45. id: mouseArea
    46. anchors.fill: parent
    47. onClicked: container.clicked()
    48. }
    49. }
    To copy to clipboard, switch view to plain text mode 



    Now, i want to use Keys.onEnterPressed event to trigger the button instead of use mouse clicked event.

    But when i attemp to replace mouseArea.pressed with Keys.onEnterPressed , start debugging program, in mainwindow.qml form, when i focus on particular button and i press Enter, the button doesn't seem to be trigger . It has no thing to be pop up in console.log() window .

    Anybody can help me, i'm very faithful for you help

  3. #3
    Join Date
    Nov 2011
    Posts
    17
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to change Gradient color of button with Enter Key Pressed Event ? :(:(

    Is there anybody can help me or show me a way to use EnterPressed Event to trigger Button instead of Mouse Clicked Event , please point this out for me

Similar Threads

  1. Replies: 4
    Last Post: 20th July 2011, 11:37
  2. How to change text color of push button?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 10:32
  3. Raise key pressed event when button is clicked?
    By newstead in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2009, 13:12
  4. Replies: 1
    Last Post: 14th September 2008, 23:05
  5. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25

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.