Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Displaying image
Forum Updated to NodeBB v4.3 + New Features

Displaying image

Scheduled Pinned Locked Moved C++ Gurus
5 Posts 4 Posters 2.7k 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
    shankarraj
    wrote on last edited by
    #1

    I am beginner in Qt.I have an startup widget. I have some controls in that. I want to display image in a widget. Can you give me some sample code to do this.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      You can start with style sheet.
      "background-image":http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-reference.html#list-of-properties must be what you're looking for.

      There are plenty of other ways to display an image though.


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        Usually "QLabel ":http://developer.qt.nokia.com/doc/qt-4.8/qlabel.html is used to display an image.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mjr_slim
          wrote on last edited by
          #4

          As the others mention there are various ways to do this. This is my implementation...
          @
          QPushButton *moveUpButton;
          ...
          moveUpButton = new QPushButton(QIcon("/path/to/jpeg/image","");
          @

          it will create a push button object with the jpeg image loaded inside the widget. More information can be found here http://developer.qt.nokia.com/doc/qt-4.8/qpushbutton.html#QPushButton-3

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rahul Das
            wrote on last edited by
            #5

            [quote author="mjr_slim" date="1326462088"]As the others mention there are various ways to do this. This is my implementation...
            @
            QPushButton *moveUpButton;
            ...
            moveUpButton = new QPushButton(QIcon("/path/to/jpeg/image","");
            @

            it will create a push button object with the jpeg image loaded inside the widget. More information can be found here http://developer.qt.nokia.com/doc/qt-4.8/qpushbutton.html#QPushButton-3[/quote]

            You can use a QPixmap as well . As a beginner , you must be interested why! That is implicit type conversion. It is there in docs.


            Declaration of (Platform) independence.

            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