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. Type cast in Qt
Qt 6.11 is out! See what's new in the release blog

Type cast in Qt

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

    Hi all,

    Can you show me how to convert following type cast expression according to Qt style?

    (qint64)nBytes
    (size_t)no_written
    
    

    Thanks

    JonBJ 1 Reply Last reply
    0
    • R russjohn834

      Hi all,

      Can you show me how to convert following type cast expression according to Qt style?

      (qint64)nBytes
      (size_t)no_written
      
      

      Thanks

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

      @russjohn834
      There is no "Qt style" for this, it's pure C++.
      Use either static_cast<qint64>(nBytes), or possibly reinterpret_cast<qint64>(nBytes) depending on your intention. Explanation in e.g. https://www.quora.com/How-do-you-explain-the-differences-among-static_cast-reinterpret_cast-const_cast-and-dynamic_cast-to-a-new-C++-programmer

      1 Reply Last reply
      7
      • R Offline
        R Offline
        russjohn834
        wrote on last edited by
        #3

        Thank you @JonB

        1 Reply Last reply
        0

        • Login

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