Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How do I show borders in a grid?
Forum Updated to NodeBB v4.3 + New Features

How do I show borders in a grid?

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 721 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parthe
    wrote on last edited by Parthe
    #1

    Hi,

    I have a window with the data set out in a QGridLayout with some cells in some rows spanning more than one cell in other rows, and I want to be able to display borders around the cells.

    I understand that I there is no option in QGridLayout, it's just a layout manager and doesn't handle visible stuff, so how might I do this?

    I've looked at QTableModel and QTableView, I know that they display cell border lines, but i cannot find a way of spanning table cells.

    I did try using a QFrame inside the grid cells but cannot get it to actually display anything useful. Maybe this would work if I could work out how but so far nada.

    This is an ASCII version of the display, if it displays OK:

    |+-------------------------Vertical box 1-----------------------------------------------+|
    ||+------------------------- Horizontal box 1 -----------------------------------------+||
    |||+----------------------- Vert Box 2  -------------------+|+-- Grid box ------------+|||
    |||+----------------------- Horiz Box 2  -----------------+|||                        ||||
    ||||Tickt number: 000 | User: xxxxx | User ref: ref        |||Next action   | person  ||||
    |||+------------------------------------------------------+|||Service       | type    ||||
    ||||-----------------------Text box------------------------|||Product       | prod    ||||
    ||||Subject: text text text text                           |||                        ||||
    |||+-------------------------------------------------------+|+------------------------+|||
    ||+---------------------------------------------------------++------------------------+|||
    |+-------------------------------------------------------------------------------------+||
    |+-------------------------Desc box----------------------------------------------------+||
    || Description: text                                                                   |||
    || Text text text                                                                      |||
    || Text text text                                                                      |||
    |+-------------------------------------------------------------------------------------+||
    +----------------------------------------------------------------------------------------+
    

    I'm out of idea, do you have any suggestions?

    M JoeCFDJ 2 Replies Last reply
    1
    • P Parthe

      Hi,

      I have a window with the data set out in a QGridLayout with some cells in some rows spanning more than one cell in other rows, and I want to be able to display borders around the cells.

      I understand that I there is no option in QGridLayout, it's just a layout manager and doesn't handle visible stuff, so how might I do this?

      I've looked at QTableModel and QTableView, I know that they display cell border lines, but i cannot find a way of spanning table cells.

      I did try using a QFrame inside the grid cells but cannot get it to actually display anything useful. Maybe this would work if I could work out how but so far nada.

      This is an ASCII version of the display, if it displays OK:

      |+-------------------------Vertical box 1-----------------------------------------------+|
      ||+------------------------- Horizontal box 1 -----------------------------------------+||
      |||+----------------------- Vert Box 2  -------------------+|+-- Grid box ------------+|||
      |||+----------------------- Horiz Box 2  -----------------+|||                        ||||
      ||||Tickt number: 000 | User: xxxxx | User ref: ref        |||Next action   | person  ||||
      |||+------------------------------------------------------+|||Service       | type    ||||
      ||||-----------------------Text box------------------------|||Product       | prod    ||||
      ||||Subject: text text text text                           |||                        ||||
      |||+-------------------------------------------------------+|+------------------------+|||
      ||+---------------------------------------------------------++------------------------+|||
      |+-------------------------------------------------------------------------------------+||
      |+-------------------------Desc box----------------------------------------------------+||
      || Description: text                                                                   |||
      || Text text text                                                                      |||
      || Text text text                                                                      |||
      |+-------------------------------------------------------------------------------------+||
      +----------------------------------------------------------------------------------------+
      

      I'm out of idea, do you have any suggestions?

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      Hi @Parthe

      In paintEvent of your window, you can draw whatever you want.

      to retreive the geometry of cells use :
      QRect QGridLayout::cellRect(int row, int column)

      1 Reply Last reply
      0
      • P Parthe

        Hi,

        I have a window with the data set out in a QGridLayout with some cells in some rows spanning more than one cell in other rows, and I want to be able to display borders around the cells.

        I understand that I there is no option in QGridLayout, it's just a layout manager and doesn't handle visible stuff, so how might I do this?

        I've looked at QTableModel and QTableView, I know that they display cell border lines, but i cannot find a way of spanning table cells.

        I did try using a QFrame inside the grid cells but cannot get it to actually display anything useful. Maybe this would work if I could work out how but so far nada.

        This is an ASCII version of the display, if it displays OK:

        |+-------------------------Vertical box 1-----------------------------------------------+|
        ||+------------------------- Horizontal box 1 -----------------------------------------+||
        |||+----------------------- Vert Box 2  -------------------+|+-- Grid box ------------+|||
        |||+----------------------- Horiz Box 2  -----------------+|||                        ||||
        ||||Tickt number: 000 | User: xxxxx | User ref: ref        |||Next action   | person  ||||
        |||+------------------------------------------------------+|||Service       | type    ||||
        ||||-----------------------Text box------------------------|||Product       | prod    ||||
        ||||Subject: text text text text                           |||                        ||||
        |||+-------------------------------------------------------+|+------------------------+|||
        ||+---------------------------------------------------------++------------------------+|||
        |+-------------------------------------------------------------------------------------+||
        |+-------------------------Desc box----------------------------------------------------+||
        || Description: text                                                                   |||
        || Text text text                                                                      |||
        || Text text text                                                                      |||
        |+-------------------------------------------------------------------------------------+||
        +----------------------------------------------------------------------------------------+
        

        I'm out of idea, do you have any suggestions?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @Parthe https://doc.qt.io/qt-5/qtableview.html#setSpan

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved