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
Forum Updated to NodeBB v4.3 + New Features

convert QByteArray to bytes

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 560 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 16 Nov 2020, 09:46 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
    
    J 1 Reply Last reply 16 Nov 2020, 10:38
    0
    • P poucz
      16 Nov 2020, 09:46

      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
      
      J Offline
      J Offline
      JonB
      wrote on 16 Nov 2020, 10:38 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 19 Nov 2020, 12:52 last edited by
        #3

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

        sudo pip3 install -upgrade  PySide2
        
        1 Reply Last reply
        0

        3/3

        19 Nov 2020, 12:52

        • Login

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