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. QList sliced vs mid and what are sublists?
Qt 6.11 is out! See what's new in the release blog

QList sliced vs mid and what are sublists?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 851 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.
  • G Offline
    G Offline
    gozag
    wrote on last edited by
    #1

    The methods sliced and mid of QList look quite similar. Are there any differences?

    The documentation also calls the return value a sub-list. What exactly is that?
    I was looking at it because I wanted to "slice off" some elements off of a list as in:

    data = data.slice(from, to);
    

    without using the iterator constructors:

    data = QList{ data.begin() + from, data.end() + to };
    
    Christian EhrlicherC 1 Reply Last reply
    0
    • G gozag

      The methods sliced and mid of QList look quite similar. Are there any differences?

      The documentation also calls the return value a sub-list. What exactly is that?
      I was looking at it because I wanted to "slice off" some elements off of a list as in:

      data = data.slice(from, to);
      

      without using the iterator constructors:

      data = QList{ data.begin() + from, data.end() + to };
      
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      There is no difference, sliced() was only added because "This keeps the API symmetric with what we have in our string classes.": https://codereview.qt-project.org/c/qt/qtbase/+/305959

      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
      1
      • G gozag 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