Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align elements in a table cell vertically #49

Open
useful-friend opened this issue Nov 23, 2023 · 5 comments
Open

Align elements in a table cell vertically #49

useful-friend opened this issue Nov 23, 2023 · 5 comments

Comments

@useful-friend
Copy link

I'd like to know if there is any way to align elements vertically in a cell of a table?

@dfaure-kdab
Copy link
Member

Yes, there is.

For TableElement there's KDReports::Cell::setVerticalAlignment.
For AutoTableElement, it comes from the Qt::TextAlignmentRole in the model.

@useful-friend
Copy link
Author

Thanks for the quick reply.
Maybe I'm wrong but i'm not able to find the KDReports::Cell::setVerticalAlignment() anywhere in the code.
I could only find QTextCharFormat::setVerticalAlignment

@dfaure-kdab
Copy link
Member

I added KDReports::Cell::setVerticalAlignment() in commit 3082185
I see now that this isn't part of any release yet, you'll have to use git master. Don't worry, it's as stable as any release.

@useful-friend
Copy link
Author

It seems that the functionality you provided is not exactly what I'm looking for and I will explain a bit to elaborate.
I'm trying to put a table with one row and three columns with dynamically changed elements in the header and facing some problems.

  1. I can't find a way to set the header height or the height of the table.
  2. I can't add a frame with 0 margin to the report or header.
  3. I want to vertically align a text element in the cell of the table but the cell height can not be adjusted so the text element will not be aligned.
    I want something like the following:
top left
middle
bottom right

The items could be any element.

by the way I wanted to thank you for the awesome job you've done so far with the KDReports.

@dfaure-kdab dfaure-kdab reopened this Dec 4, 2023
@dfaure-kdab
Copy link
Member

Hi, sorry for the delay.

  1. You can't set the header height yourself (what if it would be too small for the text inside?). You can however setCellFormatFunc to change the padding in the header, if you want to make it taller.
  2. Frame::setPadding(0) doesn't work? Please provide a testcase if not (e.g. a patch for ReferenceReport.cpp)
  3. One solution for what you're trying to achieve would be to have 3 rows instead of 1, no? You can remove the cell borders that you don't want, with setCellFormatFunc here again.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants