Results 1 to 4 of 4

Thread: Implementing a selection

  1. #1
    Join Date
    Feb 2009
    Location
    Germany, Cologne
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Implementing a selection

    Hello,

    i have some rectangles organized in rows and columns in a Qml Grid.
    But I dont have an idea how to realize a selection (including multi selection) like in QTableView.

    Can anyone give me an hint about how to implement such an issue?

    I am using Qml together with c++.
    Qt 4.7.1

    greets

  2. #2
    Join Date
    Nov 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Implementing a selection

    As far as i know, pure qml doesn't support multiselection in data views. you have to write your own qml extension in c++ with this functionality

  3. #3
    Join Date
    Feb 2009
    Location
    Germany, Cologne
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementing a selection

    Ok I think I have to explain a little bit more.

    I am not using a GridView in Qml. I would like to use a normal Grid due to the fact that I have a fixed number of rows and columns.

    I know that I need to implement the selection on my own, but thats the problem. I have no idea how to implement it.

    Does someone know an open source project where such a selection is implemented so that I can have a look at it?

  4. #4
    Join Date
    Feb 2009
    Location
    Germany, Cologne
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementing a selection

    Actually I am testing some possible implementations.


    Qt Code:
    1. import Qt 4.7
    2.  
    3. Rectangle {
    4. id: main
    5. width: 1100
    6. height: 900
    7.  
    8. MouseArea {
    9. id: area
    10. anchors.fill: parent
    11. hoverEnabled: true
    12. onPressed: {
    13. hoverEnabled = true;
    14. console.debug("x: " + mouse.x + "y: " + mouse.y);
    15. test.x = mouse.x;
    16. test.y = mouse.y;
    17. test.width = 1;
    18. test.height = 1;
    19. test.visible = true;
    20. }
    21. onReleased: {
    22. test.visible = false;
    23. hoverEnabled = false;
    24. console.debug("x: " + mouse.x + "y: " + mouse.y)
    25. }
    26.  
    27. onMousePositionChanged: {
    28. test.width = mouse.x - test.x;
    29. test.height = mouse.y - test.y;
    30. }
    31. }
    32.  
    33. Rectangle {
    34. id: test
    35. color: "blue"
    36. opacity: 0.5
    37. visible: false
    38. }
    39. }
    To copy to clipboard, switch view to plain text mode 

    When I press and move the mouse, a rectangle should be shown in this area. If I move the mouse to the right bottom, the rectangle is displayed correctly. But if I move the mouse to the left top it works not correctly.
    Qt Code:
    1. test.width = mouse.x - test.x;
    2. test.height = mouse.y - test.y;
    To copy to clipboard, switch view to plain text mode 
    This code calculates negative values in this case. It looks like negative values could not be assigned to test.widht and test.heigth.
    But if I do the following:
    Qt Code:
    1. Rectangle {
    2. x: 50; y: 50;
    3. width: -10; height: -10
    4. color: "red"
    5. }
    To copy to clipboard, switch view to plain text mode 

    It works with negative values.
    Has anyone an idea?

    greets

Similar Threads

  1. implementing 'scrollview'
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 18th December 2008, 12:23
  2. Implementing a butcon
    By Theo Landman in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2007, 20:21
  3. Implementing paint()
    By Wirloff in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2007, 10:29
  4. Implementing IME using QT
    By pmohod in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2007, 12:22

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.