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

[Building/Packaging] Build issue with Qt 5 with QList initializer #1235

Open
sebojolais opened this issue Feb 21, 2025 · 4 comments
Open

[Building/Packaging] Build issue with Qt 5 with QList initializer #1235

sebojolais opened this issue Feb 21, 2025 · 4 comments

Comments

@sebojolais
Copy link
Contributor

Describe the problem
Since this commit , this line:

https://github.com/OpenBoard-org/OpenBoard/blame/310eabe20a2838472a73e751d60b8d3e6f46d85e/src/gui/UBThumbnailScene.cpp#L36

mThumbnailItems{document->proxy()->pageCount()}

throws an error during the build with Qt5:

src/gui/UBThumbnailScene.cpp:36:7: error: no matching function for call to ‘QList<UBThumbnail*>::QList(<brace-enclosed initializer list>)’
   36 |     , mThumbnailItems{document->proxy()->pageCount()}
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:49,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qgraphicsscene.h:44,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QGraphicsScene:1,
                 from src/gui/UBThumbnailScene.h:26,
                 from src/gui/UBThumbnailScene.cpp:23:

Because the QList constructor of Qt 6 does not exist in Qt 5.

If OB does not support Qt 5 anymore, sorry for this false positive.

Versions
Provide version information for all components and libraries.

  • OpenBoard version dev branch
  • Qt version 5.15.6
@sebojolais
Copy link
Contributor Author

A solution that works for both Qt5 and 6 should be:

UBThumbnailScene::UBThumbnailScene(UBDocument* document)
    : mDocument{document}
{
    mThumbnailItems.reserve(document->proxy()->pageCount());
}

@letsfindaway
Copy link
Collaborator

Thanks for pointing this out. Qt5.15 shall still be supported!

However reserve() is not what I want. It just allocates the memory. However I want that the entries are actually created and default initialized (which means nullptr for a list of pointers).

QList has no such function, not even resize(). So I now think the best idea would be to replace this with a QVector: In Qt5, the QVector has that constructor taking a size. In Qt6, QVector and QList are even synonyms. What do you think?

@sebojolais
Copy link
Contributor Author

Thank you for your quick answer.
Yes QVector is fine.
I tested it in my side with success.

letsfindaway added a commit to letsfindaway/OpenBoard that referenced this issue Feb 21, 2025
- use QVector instead of QList
- provides constructor with size argument

Fixes OpenBoard-org#1235, thanks @sebojolais
@letsfindaway
Copy link
Collaborator

Pushed a commit on my branch which is probably the next candidate for merging and which continues the rework of the thumbnails. See letsfindaway@4dffb67

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

No branches or pull requests

2 participants