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. How to insert images in widgets..

How to insert images in widgets..

Scheduled Pinned Locked Moved General and Desktop
8 Posts 8 Posters 59.4k Views 2 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.
  • E Offline
    E Offline
    endla.ravi
    wrote on last edited by
    #1

    Hi..basically im new to Qt..

    can anyone give me a basic code to load images...

    Thanks in advance..

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #2

      You can use QPixmap to load images from several sources. If you want to show it, you can use QLabel.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kamalakshantv
        wrote on last edited by
        #3

        [quote author="endla.ravi" date="1293119280"]Hi..basically im new to Qt..

        can anyone give me a basic code to load images...

        Thanks in advance..[/quote]

        New to Qt. Exploring the SDK Doc and examples will help you a lot. There are many relevant examples.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Or looking at the "tutorials":http://doc.qt.nokia.com/latest/tutorials.html could also help to orient in Qt.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • I Offline
            I Offline
            Immii
            wrote on last edited by
            #5

            You can have code like this:
            @ QLabel mylabel;
            mylabel.setPixmap("myFile.png");
            mylabel.show();
            @

            Does this works for you?

            1 Reply Last reply
            -1
            • M Offline
              M Offline
              milot.shala
              wrote on last edited by
              #6

              You can use also "QPushButton":http://doc.qt.nokia.com/4.7/qabstractbutton.html#icon-prop to insert images if you want to have button's capabilities

              A 1 Reply Last reply
              0
              • M milot.shala

                You can use also "QPushButton":http://doc.qt.nokia.com/4.7/qabstractbutton.html#icon-prop to insert images if you want to have button's capabilities

                A Offline
                A Offline
                Ashutosh_Sachdeva
                wrote on last edited by
                #7

                @milot-shala can we also add images and popup menu at the same time in a QPushbutton.

                Or there is any other to have a image and popup menu in a single container.

                Pl45m4P 1 Reply Last reply
                0
                • A Ashutosh_Sachdeva

                  @milot-shala can we also add images and popup menu at the same time in a QPushbutton.

                  Or there is any other to have a image and popup menu in a single container.

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #8

                  @Ashutosh_Sachdeva

                  I dont think he will respond :) His last activity was back in 2011 :)

                  According your question:
                  You can add QIcons to your QPushButton and you can add Icons / Images to QComboBox-Items as well.

                  Have a look at QToolButton (https://doc.qt.io/qt-5/qtoolbutton.html#details). This might be the best solution for you.


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  2

                  • Login

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