<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hello everyone,<br><br>I've started work porting our Qt-based game from Symbian over to Sailfish and I'm hitting a pretty major roadblock at the moment. It looks like I haven't set something up in the graphics system properly and would be very grateful for any help that anyone can provide.<br><br>A brief outline:<br>* The application uses the QGraphicsView framework. We set up the QGraphicsView object once at the start of the game and then replace the QGraphicsScene object at various points as the user moves through the application.<br>* We have overriden the drawForeground() method within the QGraphicsScene objects and manually pass the QPainter object that we receive to the various elements of the UI, which use it to draw to the screen.<br>* The QGraphicsView object is set not to update itself.  We have a timer in a manager class, which fires 60 times a second, from where we manually call repaint() on the QGraphicsView object.<br><br>Current state:<br>* All code has been tidied up to build under Qt5 and non-Sailfish components, such as Phonon, are currently #ifdeffed out.<br>* On execution the game runs and moves through a couple of QGraphicsScenes, but only ever displays a white screen.  The calls to QGraphicsView::repaint() are ignored and the QDisplayScenes only have their drawForeground() methods called once, directly after instantiation.  Why we only get a white screen I'm also not sure.  This is all on the latest emulator.<br><br>An excerpt from the log is shown below with basic class hierarchy:<br>DisplayScene ->- QGraphicsScene<br>BootupScene ->- DisplayScene<br>TitleMenuScene ->- DisplayScene<br><br>0:    Using Wayland-EGL <br>1:    libpng warning: Malformed iTXt chunk<br>2: <br>3:    calling QGraphicsView::SetScene() <br>4:    DisplayScene::drawForeground  QRectF(1,1 538x958) <br>5:    BootupScene::UpdateNotification  52 <br>6:    >>GameManager::FrameTimerTick - repaint <br>7:    <<GameManager::FrameTimerTick - repaint <br>8:    BootupScene::UpdateNotification  52 <br>9:    >>GameManager::FrameTimerTick - repaint <br>10:   <<GameManager::FrameTimerTick - repaint <br>11: <br>12:   ...<br>13: <br>14:   >>GameManager::FrameTimerTick - repaint <br>15:   <<GameManager::FrameTimerTick - repaint <br>16:   BootupScene::UpdateNotification  51 <br>17;   SWITCH <br>18:   >>GameManager::FrameTimerTick - repaint <br>19:   <<GameManager::FrameTimerTick - repaint <br>20: <br>21:   calling QGraphicsView::SetScene() <br>22:   >>GameManager::FrameTimerTick - repaint <br>23:   TitleMenuScene::drawForeground <br>24:   DisplayScene::drawForeground  QRectF(1,1 538x958) <br>25:   <<GameManager::FrameTimerTick - repaint <br>26:   >>GameManager::FrameTimerTick - repaint <br>27:   <<GameManager::FrameTimerTick - repaint <br>28: <br>29:   ...<br>30:   <br>31:   >>GameManager::FrameTimerTick - repaint <br>32:   User requested stop. Shutting down...<br>33    <<GameManager::FrameTimerTick - repaint <br><br>As you can see when the GameManager calls QGraphicsView repaint() we don't get any calls to the Scenes' drawForeground().<br><br>The setup code for the QGraphicsView is:<br><br>0:    setScene(iScene);<br>1:    setOptimizationFlags(QGraphicsView::IndirectPainting);<br>2:    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);<br>3:    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);<br>4:    setRenderHint(QPainter::Antialiasing); <br>5:    setCacheMode(QGraphicsView::CacheBackground);<br>6:    setViewportUpdateMode(QGraphicsView::NoViewportUpdate);<br>7:    resize(iScreenWidth, iScreenHeight);<br>8:    viewport()->setAttribute(Qt::WA_AcceptTouchEvents);<br><br>I'm assuming the issue is either here or that I have incorrectly set up the configuration files for Sailfish.  Here's our main.cpp file:<br>MyApplication ->- QApplication<br><br>0:    int main(int argc, char *argv[])<br>1:    {<br>2:        MyApplication a(argc, argv);<br>3:<br>4:        QWidget* screen = QApplication::desktop()->screen();<br>5:        GameManager w(screen->width(), screen->height(), a);<br>6:        return a.exec();<br>7:    }<br><br>I based the Sailfish installation files off of the sample application, it's possible I made an error here.<br>Yaml:<br><br>0:    Name: PuzzleStones<br>1:    Summary: My SailfishOS Application<br>2:    Version: 0.1<br>3:    Release: 1<br>4:    Group: Qt/Qt<br>5:    License: LICENSE<br>6:    Sources:<br>7:    - '%{name}-%{version}.tar.bz2'<br>8:    Description: |<br>9:      Short description of my SailfishOS Application<br>10:   Configure: none<br>11:   Builder: qtc5<br>12:   PkgConfigBR:<br>13:   - sailfishapp<br>14:   - Qt5Quick<br>15:   - Qt5Qml<br>16:   - Qt5Core<br>17:   Requires:<br>18:   - sailfishsilica-qt5<br>19:   Files:<br>20:   - '%{_bindir}'<br>21:   - '%{_datadir}/%{name}/qml'<br>22:   - '%{_datadir}/applications/%{name}.desktop'<br>23:   - '%{_datadir}/icons/hicolor/90x90/apps/%{name}.png'<br>24:   - /usr/bin<br>25:   - /usr/share/PuzzleStones<br>26:   - /usr/share/applications<br>27:   - /usr/share/icons/hicolor/90x90/apps<br><br>Spec:<br><br>0:    # <br>1:    # Do NOT Edit the Auto-generated Part!<br>2:    # Generated by: spectacle version 0.27<br>3:    # <br>4:<br>5:    Name:       PuzzleStones<br>6:<br>7:    # >> macros<br>8:    # << macros<br>9:<br>10:   %{!?qtc_qmake:%define qtc_qmake %qmake}<br>11:   %{!?qtc_qmake5:%define qtc_qmake5 %qmake5}<br>12:   %{!?qtc_make:%define qtc_make make}<br>13:   %{?qtc_builddir:%define _builddir %qtc_builddir}<br>14:   Summary:    My SailfishOS Application<br>15:   Version:    0.1<br>16:   Release:    1<br>17:   Group:      Qt/Qt<br>18:   License:    LICENSE<br>19:   Source0:    %{name}-%{version}.tar.bz2<br>20:   Source100:  PuzzleStones.yaml<br>21:   Requires:   sailfishsilica-qt5<br>22:   BuildRequires:  pkgconfig(sailfishapp)<br>23:   BuildRequires:  pkgconfig(Qt5Quick)<br>24:   BuildRequires:  pkgconfig(Qt5Qml)<br>25:   BuildRequires:  pkgconfig(Qt5Core)<br>26:   BuildRequires:  desktop-file-utils<br>27:<br>28:   %description<br>29:   Short description of my SailfishOS Application<br>30:<br>31:<br>32:   %prep<br>33:   %setup -q -n %{name}-%{version}<br>34:<br>35:   # >> setup<br>36:   # << setup<br>37:<br>38:   %build<br>39:   # >> build pre<br>40:   # << build pre<br>41:<br>42:   %qtc_qmake5 <br>43:<br>44:   %qtc_make %{?_smp_mflags}<br>45: <br>46:   # >> build post<br>47:   # << build post<br>48:<br>49:   %install<br>50:   rm -rf %{buildroot}<br>51:   # >> install pre<br>52:   # << install pre<br>53:   %qmake5_install<br>54:<br>55:   # >> install post<br>56:   # << install post<br>57:<br>58:   desktop-file-install --delete-original       \<br>59:     --dir %{buildroot}%{_datadir}/applications             \<br>60:      %{buildroot}%{_datadir}/applications/*.desktop<br>61:<br>62:   %files<br>63:   %defattr(-,root,root,-)<br>64:   %{_bindir}<br>65:   %{_datadir}/%{name}/qml<br>66:   %{_datadir}/applications/%{name}.desktop<br>67:   %{_datadir}/icons/hicolor/90x90/apps/%{name}.png<br>68:   /usr/bin<br>69:   /usr/share/PuzzleStones<br>70:   /usr/share/applications<br>71:   /usr/share/icons/hicolor/90x90/apps<br>72:   # >> files<br>73:   # << files<br><br><br>Thank you for reading and I hope someone can help point us in the right direction.<br><br>Best regards,<br>Duncan<br>                                         </div></body>
</html>