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

Unable to get or set content in a QgsLayoutItemManualTable #44871

Closed
1 of 2 tasks
ThomasG77 opened this issue Aug 27, 2021 · 1 comment · Fixed by #46471
Closed
1 of 2 tasks

Unable to get or set content in a QgsLayoutItemManualTable #44871

ThomasG77 opened this issue Aug 27, 2021 · 1 comment · Fixed by #46471
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API

Comments

@ThomasG77
Copy link
Contributor

ThomasG77 commented Aug 27, 2021

What is the bug or the crash?

I'm unable to get or set table content in a QgsLayoutItemManualTable and it crashes when trying to inspect existing manual table created using GUI.

You can find attached a minimum project (one layout with an existing item, no layers) to test my code

debug-fixed-content-layout.qgz.zip

Steps to reproduce the issue

Open the attached project

Open the PyQGIS console and execute first part

layout_name = 'demo1'
project = QgsProject.instance()
manager = project.layoutManager()
layout = manager.layoutByName(layout_name)
my_item = layout.itemById('debug')
my_frame = my_item.multiFrame()
# Working
print(my_frame.contents())

headers = ['header1', 'header2', 'headerother']
content = [[1, 2, 3], [4, 5, "debug3"]]
result = [[QgsTableCell(f'{c}') for c in line] for line in content]

my_frame.setHeaders([QgsLayoutTableColumn(h) for h in headers])

Then, line by line, execute the following to reproduce the issue

# Below line failed and complains about not accepting a list
my_frame.setTableContents(result)
# Was wondering why, so done. Expecting an object
# but the object is supposed to be a QgsLayoutTableContents of
# QgsLayoutTableRow of QgsTableCell and neither QgsLayoutTableContents
# and QgsLayoutTableRow are available in Python bindings
print(help(my_frame.setTableContents))

# Below line crash QGIS
my_frame.tableContents()

Versions

QGIS version
3.16.3-Hannover
QGIS code revision
94ac9f2
Compiled against Qt
5.9.5
Running against Qt
5.9.5
Compiled against GDAL/OGR
2.2.3
Running against GDAL/OGR
2.2.3
Compiled against GEOS
3.6.2-CAPI-1.10.2
Running against GEOS
3.7.1-CAPI-1.11.1 27a5e771
Compiled against SQLite
3.22.0
Running against SQLite
3.22.0
PostgreSQL Client Version
10.15 (Ubuntu 10.15-0ubuntu0.18.04.1)
SpatiaLite Version
4.3.0a
QWT Version
6.1.3
QScintilla2 Version
2.10.2
PROJ.4 Version
493
OS Version
Ubuntu 18.04.5 LTS
Active python plugins
processing_r;
exportDBmapper;
autoSaver;
LayerBoard;
qtiles;
ImageServerConnector;
qgis_resource_sharing;
processing_wbt;
profiletool;
QuickOSM;
splitmultipart;
quick_map_services;
geometry_paster;
qgisnetworklogger;
french_address;
qgis-maptiler-plugin;
DEMto3D;
SgmExpressionFunctions;
cartolinegen;
geo_sim_processing;
pluginbuilder3;
PluginLoadTimes;
DotMap;
firstaid;
cartography_tools;
qfieldsync;
mask;
qgis2web;
InvisibleLayersAndGroups;
Generalizer3;
lizmap;
french_locator_filter;
plugin_reloader;
LoadQSS;
db_manager;
processing

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@ThomasG77 ThomasG77 added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Aug 27, 2021
@gioman gioman added the PyQGIS Related to the PyQGIS API label Aug 27, 2021
@nyalldawson nyalldawson self-assigned this Dec 14, 2021
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Dec 14, 2021
@ThomasG77
Copy link
Contributor Author

@nyalldawson Thanks for the fix

manisandro pushed a commit to kadas-albireo/QGIS that referenced this issue Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants