How to handle Pictures



  • Hello,

    for my first python program I try to build a user interface for a litle address database. Therefor I use pyqt to build the formular, and later I will connect it to an existing SQLite DB, using APSW.

    Besides the "normal" things as name, address, email and others I want to store an image. Normaly that will be given as a file (.jpg, .png, or other type). I would let the user find the picture with a QFileDialog.getOpenFileName() dialog. But what to do after that? Here are my questions (may be not all of them are at the right place here):

    Which widget is able to show the picture?

    How to show the picture? That means: howto put the picture from the file into the widget?

    How to put the picture data into an blob(?) column in the database?

    How to get the data back from there and bring it in the widget?

    May be there is a tutorial which I didn't find yet?

    Thank's a lot for any help!

    Greetings
    Ulrich


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    1. QLabel
    2. You have all the information needed in QLabel's documentation
      3-4 Have a look at the QtSql module, you have also the examples there that will help you get started. If you really want to save that in a blob just load the file content, maybe encode it in base64 to avoid char conversion problem and store it. Most of this can be found in the examples. For your blob column, you need to look at the Model/View documentation and related classes/examples.

    Hope it helps

    Happy coding !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.