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. Show QImage information on QTextBrowser
Forum Updated to NodeBB v4.3 + New Features

Show QImage information on QTextBrowser

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 481 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.
  • S Offline
    S Offline
    sogo
    wrote on last edited by
    #1

    Hi,
    I would like to know is there a way we can show Image information such as size, format, aspect ratio from QImage class on QTextBrowser. I have an image viewer desktop application and designated an area on application for showing such image information. Presently I am trying with QTextBrowser to show QImage information but as QTextBrowser uses string to setText, the output from QImage is not string.

    P.S. Any alternative method to QTextBrowser to show image information on my app is also welcome .
    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forums

      Im not 100% sure what the issue was using TextBrowser as you say

      • as QTextBrowser uses string to setText, the output from QImage is not string.

      So you needed something like
      QString info;
      info = "Image width:" + QString::number( someimage.width() );
      info += "Image height:" + QString::number( someimage.height() );
      ..
      to convert from integers to text ?

      Or can you tell abit more about the actual issue?

      S 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi and welcome to the forums

        Im not 100% sure what the issue was using TextBrowser as you say

        • as QTextBrowser uses string to setText, the output from QImage is not string.

        So you needed something like
        QString info;
        info = "Image width:" + QString::number( someimage.width() );
        info += "Image height:" + QString::number( someimage.height() );
        ..
        to convert from integers to text ?

        Or can you tell abit more about the actual issue?

        S Offline
        S Offline
        sogo
        wrote on last edited by
        #3

        @mrjj Yes, I am looking for something like this. While this works for numbers, can I do something to get QImage::Format, such as
        info = "Image format:" + QString::_____( someimage.format() );
        I am not sure what is return type of "someimage.format()"

        As I wrote, to show image specific information on my application, my first idea went towards QTextBrowser to show as text by converting information from QImage class. Does QT has any other way to show such information for images more efficiently because I could not find any.

        Thanks for quick response...

        mrjjM 1 Reply Last reply
        0
        • S sogo

          @mrjj Yes, I am looking for something like this. While this works for numbers, can I do something to get QImage::Format, such as
          info = "Image format:" + QString::_____( someimage.format() );
          I am not sure what is return type of "someimage.format()"

          As I wrote, to show image specific information on my application, my first idea went towards QTextBrowser to show as text by converting information from QImage class. Does QT has any other way to show such information for images more efficiently because I could not find any.

          Thanks for quick response...

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @sogo
          Hi
          https://doc.qt.io/qt-5/qimage.html#Format-enum

          Its an enum. They are normally just values, but Qt has some tricks.

          You can convert to text like

          QMetaEnum metaEnum = QMetaEnum::fromType<QImage::Format>();
          info +=metaEnum.valueToKey(test.format());
          

          test is the actual image.

          Qt do not have a ImageInformationWidget.

          S 1 Reply Last reply
          1
          • mrjjM mrjj

            @sogo
            Hi
            https://doc.qt.io/qt-5/qimage.html#Format-enum

            Its an enum. They are normally just values, but Qt has some tricks.

            You can convert to text like

            QMetaEnum metaEnum = QMetaEnum::fromType<QImage::Format>();
            info +=metaEnum.valueToKey(test.format());
            

            test is the actual image.

            Qt do not have a ImageInformationWidget.

            S Offline
            S Offline
            sogo
            wrote on last edited by
            #5

            @mrjj Hi,
            I see. I didn't realize enum is a type. This works, can mark this thread as solved.

            Thanks a lot

            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