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. class QList<QString> has no member named 'emplace_back'

class QList<QString> has no member named 'emplace_back'

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 204 Views
  • 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.
  • M Offline
    M Offline
    mortem
    wrote on last edited by mortem
    #1

    Hello,
    I'm getting this problem
    class QList<QString> has no member named 'emplace_back'

    for code
    QList<QString> list;
    list.emplace_back("string");

    Other members like append and such seem to work as intended. There is no emplaceBack() either however. Any help is much appreciated!

    QTVersion: 6.8.2
    QTCreator: 15.0.1

    I made sure that I have QT6 by appending QStringView to a QString and it worked fine. All my kits have 6.8.2. Pressing F2 to go the header file shows that there is no emplace anything in there.

    JonBJ 1 Reply Last reply
    0
    • M mortem

      Hello,
      I'm getting this problem
      class QList<QString> has no member named 'emplace_back'

      for code
      QList<QString> list;
      list.emplace_back("string");

      Other members like append and such seem to work as intended. There is no emplaceBack() either however. Any help is much appreciated!

      QTVersion: 6.8.2
      QTCreator: 15.0.1

      I made sure that I have QT6 by appending QStringView to a QString and it worked fine. All my kits have 6.8.2. Pressing F2 to go the header file shows that there is no emplace anything in there.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @mortem said in class QList<QString> has no member named 'emplace_back':

      There is no emplaceBack() either however

      template <typename... Args> QList<T>::reference QList::emplaceBack(Args &&... args)

      Are you saying that does not compile?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        It looks like there's something off with your sources. The methods have been available since 5.15 and the current dev branch has them as well.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mortem
          wrote on last edited by
          #4

          Ok I fixed it somehow in CMakeLists. CMakeLists.txt had

          find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
          
          1. I removed Qt5 from there
          2. set(PROJECT_SOURCES did NOT have the files I had added while building the program. They were being added later in the else-clause in cmake logic so I added the missing ones to PROJECT_SOURCES. The code below was the situation before the fix
          set(PROJECT_SOURCES
                  main.cpp
                  mainwindow.cpp
                  mainwindow.h
                  mainwindow.ui
          )
          if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
              qt_add_executable(Gridlink
                  MANUAL_FINALIZATION
                  ${PROJECT_SOURCES}
              )
          # Define target properties for Android with Qt 6 as:
          #    set_property(TARGET Gridlink APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
          #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
          # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
          else()
              if(ANDROID)
                  add_library(Gridlink SHARED
                      ${PROJECT_SOURCES}
                  )
          # Define properties for Android with Qt 5 after find_package() calls as:
          #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
              else()
                  add_executable(Gridlink
                      ${PROJECT_SOURCES}
                      searchview.h searchview.cpp searchview.ui
                      mpd_communication.h mpd_communication.cpp
                      libraryview.h libraryview.cpp libraryview.ui
                      artistview.h artistview.cpp artistview.ui
                      albumview.h albumview.cpp albumview.ui
                      datahandler.h datahandler.cpp
                      config.h config.cpp
                      song.h song.cpp
                      album.h album.cpp
                  )
              endif()
          endif()
          
          1 Reply Last reply
          0
          • M mortem has marked this topic as solved on

          • Login

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