Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mixing QT with C++ Standard Library
Forum Updated to NodeBB v4.3 + New Features

Mixing QT with C++ Standard Library

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 2.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TauCeti
    wrote on last edited by TauCeti
    #1

    Hi,

    is it feasible to mix QT commands with Standard Library
    commands?

    1. as far as I know QT Container are compatible with
      std-<algorithm> and std-iterators. Is this correct?
      Is this feasible? Does anybody use it?
      Does one need special considerations?

    2. What std commands do you use in your QT code?
      Can you provide examples?
      e.g. std::sort() seems useful for me.

    3. Do you also mix std containers with QT container in one
      project?

    Thanks for help.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      See https://doc.qt.io/qt-5/containers.html
      I don't see a reason why it should not be mixed but you should not convert it the whole time.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        I am generally paranoid of mixing Qt containers with STL containers, but have no qualms about using STL for platform independent modules that need to exist within a Qt app. I just make sure to do explicit conversions if the behaviour documentation doesn't meet my standards. It usually does not.

        JKSHJ 1 Reply Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          I am generally paranoid of mixing Qt containers with STL containers, but have no qualms about using STL for platform independent modules that need to exist within a Qt app. I just make sure to do explicit conversions if the behaviour documentation doesn't meet my standards. It usually does not.

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @Kent-Dorfman said in Mixing QT with C++ Standard Library:

          I am generally paranoid of mixing Qt containers with STL containers

          Why's that? Have you experienced issues?

          @TauCeti said in Mixing QT with C++ Standard Library:

          is it feasible to mix QT commands with Standard Library
          commands?

          Yes.

          1. as far as I know QT Container are compatible with
            std-<algorithm> and std-iterators. Is this correct?
            Is this feasible? Does anybody use it?
            Does one need special considerations?

          Yes. Yes. Yes. Yes.

          For your last question, see the Implicitly Shared Iterator Problem: https://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem

          1. What std commands do you use in your QT code?
            Can you provide examples?
            e.g. std::sort() seems useful for me.

          2. Do you also mix std containers with QT container in one
            project?

          I quite happily do things like:

          • Put QString in a std::pair
          • Put std::shared_ptr<MyStruct> inside a QVector
          • Use std::sort(), std::copy_if() on my QVector

          However, I avoid converting a Qt container to an STL container and vice-versa, like @Christian-Ehrlicher said.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved