How to insert images in widgets..
-
Hi..basically im new to Qt..
can anyone give me a basic code to load images...
Thanks in advance..
-
You can use QPixmap to load images from several sources. If you want to show it, you can use QLabel.
-
[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.
-
Or looking at the "tutorials":http://doc.qt.nokia.com/latest/tutorials.html could also help to orient in Qt.
-
You can have code like this:
@ QLabel mylabel;
mylabel.setPixmap("myFile.png");
mylabel.show();
@Does this works for you?
-
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
-
@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.
-
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.