Results 1 to 7 of 7

Thread: border around tableView not working

  1. #1
    Join Date
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: border around tableView not working

    not able to get a border to display using REctangle obj or frame in tableView

    Qt Code:
    1. Rectangle {
    2. id: tableViewRect
    3. width: 880
    4. height: 490
    5. anchors.verticalCenter: parent.verticalCenter
    6. anchors.left: parent.left
    7. anchors.leftMargin: 10
    8. border.width: 10
    9. border.color: "lightsteelblue"
    10. color: "transparent"
    11. TableView {
    12. id: tableView
    13. anchors.fill: parent
    14. sortIndicatorVisible: true
    15. sortIndicatorOrder: 1
    16. sortIndicatorColumn: 1
    17. frameVisible: true
    18. model: UserEventLog
    19. style: TableViewStyle {
    20. // frame: Rectangle {
    21. // border.color: "lightsteelblue"
    22. // border.width: 50
    23. // }
    24. headerDelegate: Rectangle {
    25. height: textItem.implicitHeight * 1.2
    26. width: textItem.implicitWidth
    27. color: "lightsteelblue"
    28. Text {
    29. id: textItem
    30. anchors.centerIn: parent
    31. text: styleData.value
    32. }
    33. Rectangle {
    34. anchors.right: parent.right
    35. anchors.top: parent.top
    36. anchors.bottom: parent.bottom
    37. width: 3
    38. color: "yellow"
    39. }
    40. }
    41. }
    42. TableViewColumn {
    43. role: "id"
    44. title: "id"
    45. width: 100
    46. }
    47. TableViewColumn {
    48. role: "userName"
    49. title: "User Name"
    50. width: 200
    51. }
    52. TableViewColumn {
    53. role: "eventMessage"
    54. title: "Event Message"
    55. width: 372
    56. }
    57. TableViewColumn {
    58. role: "dateTime"
    59. title: "Date Time"
    60. width: 201
    61. }
    62. }
    63. }
    To copy to clipboard, switch view to plain text mode 

    update: I get the border to kinda show up but cant adjust width an it does not wrap around the hole table...

    Qt Code:
    1. style: TableViewStyle {
    2. frame: Rectangle {
    3. border{
    4. color: "red"
    5. width: 10
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 


    Added after 44 minutes:


    found a solution: just messed around with my outer object rectangle and anchoring got a border around my tableView now! I made the rectangle little larger than tableView then enter tableView in the Rect.

    Qt Code:
    1. Rectangle {
    2. width: 880
    3. height: 490
    4. anchors.verticalCenter: parent.verticalCenter
    5. anchors.left: parent.left
    6. anchors.leftMargin: 10
    7. color: "transparent"
    8. radius: 7
    9. border.color: "lightsteelblue"
    10. border.width: 5
    11. visible: true
    12. TableView {
    13. id: tableView
    14. width: 870
    15. height: 480
    16. anchors.centerIn: parent
    17. sortIndicatorVisible: true
    18. sortIndicatorOrder: 1
    19. sortIndicatorColumn: 1
    20. //frameVisible: true
    21. model: UserEventLog
    22. style: TableViewStyle {
    23. headerDelegate: Rectangle {
    24. height: textItem.implicitHeight * 1.2
    25. width: textItem.implicitWidth
    26. color: "lightsteelblue"
    27. Text {
    28. id: textItem
    29. anchors.centerIn: parent
    30. text: styleData.value
    31. }
    32. Rectangle {
    33. anchors.right: parent.right
    34. anchors.top: parent.top
    35. anchors.bottom: parent.bottom
    36. width: 3
    37. color: "yellow"
    38. }
    39. }
    40. }
    41. TableViewColumn {
    42. role: "id"
    43. title: "id"
    44. width: 100
    45. }
    46. TableViewColumn {
    47. role: "userName"
    48. title: "User Name"
    49. width: 200
    50. }
    51. TableViewColumn {
    52. role: "eventMessage"
    53. title: "Event Message"
    54. width: 372
    55. }
    56. TableViewColumn {
    57. role: "dateTime"
    58. title: "Date Time"
    59. width: 201
    60. }
    61. }
    62. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jfinn88; 19th September 2016 at 19:26.

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

    Default Re: border around tableView not working

    Why not simply:

    javascript Code:
    1. TableView {
    2. id: tv
    3. // ...
    4. }
    5.  
    6. Rectangle {
    7. anchors.fill: tv
    8. border { color: "black"; width:2 }
    9. color: "transparent"
    10. }
    To copy to clipboard, switch view to plain text mode 
    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
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: border around tableView not working

    that looks little cleaner I can try that

    I don't see a hole lot of difference other than the rectangle wouldn't be a parent obj of the tableView... I'm I missing something

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

    Default Re: border around tableView not working

    My code exposes TableView interface to the outside world. Your code exposes Rectangle interface to the outside world. Since you want to have a table view with a border rather than a box with a table view inside, my code seems a more direct approach to obtain what you want.
    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. The following user says thank you to wysota for this useful post:

    jfinn88 (20th September 2016)

  6. #5
    Join Date
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: border around tableView not working

    I see... thank you for the explanation, it helped a lot in understanding what I want to achieve

  7. #6
    Join Date
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: border around tableView not working

    I have messed around with your suggestion, it makes sense to do it like that after your explanation however it doesn't give visually what I need It puts the border inside of the table instead of around the out side is there away to make go on the outside of the table? its the fill anchor that needs changed but not sure what to try. If you use the rect obj as the parent of the table view it gives visually what I want is there any benefit to exposing the table vs a rect with a table view in it

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

    Default Re: border around tableView not working

    Quote Originally Posted by jfinn88 View Post
    it doesn't give visually what I need It puts the border inside of the table instead of around the out side
    So make the box bigger by half the border size.
    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.


Similar Threads

  1. Replies: 10
    Last Post: 9th September 2013, 15:29
  2. How to Drag and Drop working with tableview?
    By diginikkari in forum Newbie
    Replies: 2
    Last Post: 22nd October 2012, 18:02
  3. Replies: 7
    Last Post: 24th September 2012, 07:17
  4. Replies: 2
    Last Post: 21st March 2012, 14:30
  5. Border-image not working in QWidget?
    By astampor in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2011, 15:16

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.