Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. convert QByteArray to bytes
QtWS25 Last Chance

convert QByteArray to bytes

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 548 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.
  • P Offline
    P Offline
    poucz
    wrote on last edited by
    #1

    Hello,
    I need convert QByteArray to standart pythons bytes.
    I try convert it but I recieve SIGSEGV.
    //Python 3.7.3 , PySide2 5.13.2

    Can you please help me??

    from PySide2.QtCore import QByteArray
    
    pba=b'\x00\x02'
    qba=QByteArray(b'\x00\x02')
    # convert=bytes(qba)  # SIGSEGV
    
    print("pba typ:"+str(type(pba))+" val:"+str(pba))
    print("qba typ:"+str(type(qba))+" val:"+str(qba))
    
    print("Int pba:"+str(int.from_bytes(pba, byteorder="big", signed=True)))
    print("Int qba:"+str(int.from_bytes(qba, byteorder="big", signed=True)))     #SIGSEGV
    
    JonBJ 1 Reply Last reply
    0
    • P poucz

      Hello,
      I need convert QByteArray to standart pythons bytes.
      I try convert it but I recieve SIGSEGV.
      //Python 3.7.3 , PySide2 5.13.2

      Can you please help me??

      from PySide2.QtCore import QByteArray
      
      pba=b'\x00\x02'
      qba=QByteArray(b'\x00\x02')
      # convert=bytes(qba)  # SIGSEGV
      
      print("pba typ:"+str(type(pba))+" val:"+str(pba))
      print("qba typ:"+str(type(qba))+" val:"+str(qba))
      
      print("Int pba:"+str(int.from_bytes(pba, byteorder="big", signed=True)))
      print("Int qba:"+str(int.from_bytes(qba, byteorder="big", signed=True)))     #SIGSEGV
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @poucz said in convert QByteArray to bytes:

      convert=bytes(qba) # SIGSEGV
      print("Int qba:"+str(int.from_bytes(qba, byteorder="big", signed=True))) #SIGSEGV

      Both of these work fine for me. Ubuntu 20.04, Python 3.8.5, Qt/PySide2 either 5.12.8 or 5.15.0, not sure which (but I think the latter)!

      1 Reply Last reply
      0
      • P Offline
        P Offline
        poucz
        wrote on last edited by
        #3

        Thank you,
        after update it working!!
        Amazing....

        sudo pip3 install -upgrade  PySide2
        
        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