Displaying image
-
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.
-
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.
-
Usually "QLabel ":http://developer.qt.nokia.com/doc/qt-4.8/qlabel.html is used to display an image.
-
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 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.