qt: Replace functions deprecated in Qt 5.13 #16701

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:20190823-qt13-deprecated changing 7 files +34 −17
  1. hebasto commented at 6:41 PM on August 23, 2019: member

    The following functions are obsolete in Qt 5.13:

    This PR replaces them and does not change behavior.

    Here are some excerpts from the master build log:

    qt/bitcoingui.cpp: In constructor ‘BitcoinGUI::BitcoinGUI(interfaces::Node&, const PlatformStyle*, const NetworkStyle*, QWidget*)’:
    qt/bitcoingui.cpp:84:57: warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
             move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
                                                             ^
    In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDesktopWidget:1:0,
                     from qt/bitcoingui.cpp:43:
    /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdesktopwidget.h:88:67: note: declared here
         QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect availableGeometry(int screen = -1) const;
                                                                       ^~~~~~~~~~~~~~~~~
    
    qt/bitcoingui.cpp:1410:74: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
             max_width = qMax(max_width, fm.width(BitcoinUnits::longName(unit)));
                                                                              ^
    In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qwidget.h:50:0,
                     from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdialog.h:44,
                     from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDialog:1,
                     from ./qt/optionsdialog.h:8,
                     from ./qt/bitcoingui.h:12,
                     from qt/bitcoingui.cpp:5:
    /home/hebasto/Qt/5.13.0/gcc_64/include/QtGui/qfontmetrics.h:108:9: note: declared here
         int width(const QString &, int len = -1) const;
             ^~~~~
    
    qt/splashscreen.cpp: In constructor ‘SplashScreen::SplashScreen(interfaces::Node&, Qt::WindowFlags, const NetworkStyle*)’:
    qt/splashscreen.cpp:127:50: warning: ‘const QRect QDesktopWidget::screenGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
         move(QApplication::desktop()->screenGeometry().center() - r.center());
                                                      ^
    In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDesktopWidget:1:0,
                     from qt/splashscreen.cpp:24:
    /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdesktopwidget.h:79:67: note: declared here
         QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect screenGeometry(int screen = -1) const;
                                                                        ^~~~~~~~~~~~~~
    
  2. qt: Add TextWidth() wrapper
    In Qt 5.12 and before the QFontMetrics::width() is used and it is
    deprecated since Qt 13.0.
    In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
    1260ecd812
  3. DrahtBot commented at 6:44 PM on August 23, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15768 (gui: Add close window shortcut by IPGlider)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label GUI on Aug 23, 2019
  5. jonatack commented at 8:50 PM on August 23, 2019: member

    Concept ACK, saw these warnings just now while building with Qt 5.13.0 on macOS.

  6. hebasto renamed this:
    qt: Replace functions deprecated in Qt 5.13 (partly)
    qt: Replace functions deprecated in Qt 5.13
    on Aug 24, 2019
  7. in src/qt/bitcoingui.cpp:84 in 68e2d767dd outdated
      81 | @@ -81,7 +82,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
      82 |      QSettings settings;
      83 |      if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
      84 |          // Restore failed (perhaps missing setting), center the window
      85 | -        move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
    


    promag commented at 12:36 AM on August 25, 2019:

    68e2d767ddea56c447fcea1cc0766ea6038da311

    Can remove #include <QDesktopWidget>?


    hebasto commented at 5:50 AM on August 25, 2019:

    Done.

  8. in src/qt/splashscreen.cpp:127 in 68e2d767dd outdated
     124 | @@ -124,7 +125,7 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
     125 |      QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio));
     126 |      resize(r.size());
     127 |      setFixedSize(r.size());
     128 | -    move(QApplication::desktop()->screenGeometry().center() - r.center());
    


    promag commented at 12:37 AM on August 25, 2019:

    68e2d767ddea56c447fcea1cc0766ea6038da311

    Same.


    hebasto commented at 5:50 AM on August 25, 2019:

    Done.

  9. in src/qt/guiutil.cpp:959 in 1260ecd812 outdated
     955 | @@ -956,4 +956,13 @@ void PolishProgressDialog(QProgressDialog* dialog)
     956 |  #endif
     957 |  }
     958 |  
     959 | +int TextWidth(const QFontMetrics& fm, const QString& text)
    


    promag commented at 12:40 AM on August 25, 2019:

    1260ecd812e35185898fd555ad3e01d019072bcf

    Isn't it better to use a deprecated function instead of implementing workarounds? IMHO deprecated stuff can be removed only when it's 1-to-1. So in this case this change sounds premature.


    hebasto commented at 5:56 AM on August 25, 2019:

    IMHO deprecated stuff can be removed only when it's 1-to-1.

    Unfortunately, Qt's "support version window" (for the mentioned feature), i.e., 5.11 to 5.13, is narrower than ours, i.e., 5.5.1 to 5.13.

  10. qt: Replace obsolete functions of QDesktopWidget c6dd32da69
  11. hebasto force-pushed on Aug 25, 2019
  12. jonasschnelli approved
  13. jonasschnelli commented at 7:02 AM on August 26, 2019: contributor

    utACK c6dd32da697e5a8052cbabe8c7605d27c43a8dfb

    Abstracting it into our helper layer seems a good approach.

  14. laanwj approved
  15. laanwj commented at 12:57 PM on August 29, 2019: member

    I think qt is over-zealous here with renaming, but that's not our fault, utACK c6dd32da697e5a8052cbabe8c7605d27c43a8dfb

  16. laanwj referenced this in commit d20d171f26 on Aug 29, 2019
  17. laanwj merged this on Aug 29, 2019
  18. laanwj closed this on Aug 29, 2019

  19. hebasto deleted the branch on Aug 29, 2019
  20. sidhujag referenced this in commit b275870df0 on Aug 29, 2019
  21. fanquake referenced this in commit f5db3f2128 on Aug 30, 2019
  22. deadalnix referenced this in commit 93934d3b80 on Feb 29, 2020
  23. ftrader referenced this in commit 1b67393761 on Apr 16, 2020
  24. PastaPastaPasta referenced this in commit 170c1c9d64 on Sep 11, 2021
  25. PastaPastaPasta referenced this in commit d2492b6f31 on Sep 11, 2021
  26. PastaPastaPasta referenced this in commit b42e8ef500 on Sep 12, 2021
  27. PastaPastaPasta referenced this in commit f99d692e91 on Sep 12, 2021
  28. PastaPastaPasta referenced this in commit 1d6920fa69 on Sep 12, 2021
  29. PastaPastaPasta referenced this in commit ac03841c46 on Sep 14, 2021
  30. kittywhiskers referenced this in commit 995fe2cb48 on Nov 6, 2021
  31. kittywhiskers referenced this in commit 93cee38593 on Dec 5, 2021
  32. kittywhiskers referenced this in commit d4a1decb73 on Dec 5, 2021
  33. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me