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. What is the best way to show multiple pictures on a widget?

What is the best way to show multiple pictures on a widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 26 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mbkerdellou
    wrote last edited by
    #1

    Hello, I've just started learning QT recently for a school project and I am unsure about something.

    This is what I have right now, but it is written in an unmaintainable and ugly way.

    01314d7c-3ea6-4b7b-9f64-a5c2a872c579-image.png

    For each widget in the grid layout, i want to show three things, tile texture : static and a character texture and healthbar (character is image, healthbar currently im using a qwidget with a linear gradient stylesheet, but that's not a good solution, both change place on every turn).

    I am not asking how to handle the changes, but how to actually draw them on the QWidget. Is the best solution creating three QLabels, setting a pixmap to each, and setting QTile as their parent? I have tried using QPainter but it seems that for that I have to change the paintEvent function? I am not looking for the actual code but just directions.

    Thanks

    1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by JonB
      #2

      If I were writing this "for real": each QWidget comes with quite some overhead. You already have 100, then you are talking about 3 pixmaps per widget making it 300, and it won't scale well if you increase the number of pictures you want.

      I would probably use something from: (a) forget widgets and go QGrapicsScene/View, (b) do it as a QAbstractTableModel + QTableView with your own QStyledItemDelegate to draw the picture or (c) maybe some kind of single "table" widget with each pic painted at whatever position on it.

      Of course I quite understand if you don't want to do one of those or the purpose of the project is to use multiple widgets like you have at the moment. It also depends on what you are intending to do with this screen/pictures and your end user. You may wait to see if others agree or disagree with me.

      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