Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating a table editor
Forum Updated to NodeBB v4.3 + New Features

Creating a table editor

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.1k 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.
  • D Offline
    D Offline
    d2uriel
    wrote on last edited by
    #1

    Dear Qt programmers and developers,

    I'm creating (as some of you already noticed ;-) ) a table editing application. Everything went almost perfect up to this moment. You guys helped me a lot along the way but I guess I need to bother you some more. I'm starting to think that what I'm trying to do is not possible with choices I've made. I'd like to ask for a piece of advice.

    My editor should be capable of:

    • Managing table size (row and column count along with their heights and widths),
    • Allowing removing and adding of rows/columns,
    • Allowing cell spanning,
    • Changing font properties (bold, italics, underline, color, etc.),
    • Changing background color,
      /* Everything works up to this point */
    • Changing border style <- this is the point I got stuck at.

    I'm inheriting QTableWidget class to do the stuff I mentioned above. It seems though, that I cannot use it to modify the borders of the table. I know I can hide/show the grid - but that works for the whole grid, not parts of it. I can use styles to modify the looks of a single cell but then it's going to have an "internal" border along with the grid (which will look awful). I would actually like to paint the grid itself the way I want it to be painted (i.e. only a border around the whole table and no borders inside).

    My whole concept is being ruined now. I've put a lot of work in this project and now it seems I'm in a dead end. I'm not really a professional programmer so it really takes some time to program and learn Qt framework (which, as a side note, is really great).

    My question is: should I inherit from QAbstractItemView class and create my own table view class which painting I can adapt to my own needs? Or maybe there is an elegant way of using QTableWidget to actually modify the grid?

    Your help is greatly appreciated.

    Daniel.

    "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on last edited by
      #2

      If I wew you, I would first try to read QTableView:paintEvent() implementation, which will give you quite lots of hint

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • D Offline
        D Offline
        d2uriel
        wrote on last edited by
        #3

        Umm... if I guessed your hint correctly - here it is:
        @option.rect = QRect(colp + (showGrid && rightToLeft ? 1 : 0), rowY, colw, rowh);@
        What it means is that if I will not paint the grid then all the cells will be closer together. Is that what you were suggesting?

        Edit: not really... still playing around with it.

        Edit #2: I managed to paint my own grid for the table. Now I need to solve some issues when painting cells. When I call the default paint() method of QStyledItemDelegate the QStyleOptionViewItem contains invalid coordinates. Take a look at the image:
        !http://img207.imageshack.us/img207/3631/cellselected.png(Cell selection)!
        As you can see the selection is being painted not exactly where it should. But I guess I'm going to manage fixing that. If not, I'll post here again.

        "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

        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