Last edited by nimrod1989; 16th March 2014 at 19:44.
The frame. It's a button like any other button. Place three QToolButtons on the frame and set their sizes. You can add icons from your app.
Ok, I've done this.
Here is how it looks like:Qt Code:
"E:\\Personal\\TestImageLoaderQt", tr("Images (*.jpg")); ui.pushButtonUp->setIcon(imgIcon);To copy to clipboard, switch view to plain text mode
QIconOnPushButtons.png
Unfortunately, the iconSize seems to depend on the image which I'm loading. The IconSize is not set as expected with the related values (100, 80). It depends the image I'm loading, its width and height.
My pushButtons have this size(100, 80); It seems that I need to scale this QIcon on my pushButton. I didn't find any functions which implements this.
Does anybody have another approach for this? Maybe I should try to use something else, instead my pushButtons?
(1) Scaling pixmaps: see QPixmap::scaled()
(2) When you setIcon() the icon is displayed on the button. The subsequent setIconSize() will change nothing.
Therefore:
Qt Code:
ui.PushButtonUp->setIcon(imgIcon);To copy to clipboard, switch view to plain text mode
Hallo everyone,
I like this form, place tell me why use design QT ?
thank,s
I want to thank you for all the help. Unfortunately, using a QIcons on the related buttons doesn't fulfill my expectations. First of all, I cannot cover a QButton without distorting the image.
So, I would like to have a different approach. Does anybody have any idea what I could try?
OMG! The buttons have some sizes. The icons, as I have seen, have another sizes. Something needs to be "distorted", this cannot be helped. Either prepare "undistorted" icons for the buttons in advance (use some image processor, for example GIMP, for it) or use QListView in Icon mode. In the later case, you get an "icon view", as you know it from file managers, where you can place icons with different sizes. I am afraid, there is no other acceptable solution.
Hi Radek,
I think I have something which is pretty much what I've wanted. Here's how it looks like:
CurrentView.png
So, when I double click on an item from my QListView, the related item will be displayed on my central label. The Up and Down buttons will be deleted from the UI since there is no need of them (you can navigate through the QListWidget using its scroolBar).
Here's my code
When an item is doubleClicked(), I update my central Qlabel which display the image in a preview mode. Unfortunately, I need somehow to scale my label which holds my image in order to be properly displayed (not the image to be scaled in order to fit in my QLabel. The QLabel needs to be scaled upon the image sizes).Qt Code:
"E:\\Personal\\TestImageLoaderQt", tr("Images (*.jpg")); //get the pixList for(int i = 0; i < listaPics.size(); i ++) { pixList.append(imgPixmap); } for (int i = 0; i < pixList.size(); ++i) { listWindgetItemImage->setIcon(*iconImage); ui.listWidgetImage->addItem(listWindgetItemImage); }To copy to clipboard, switch view to plain text mode
Have any tips about this?
If I understand well, the central (picture displaying) widget is a QLabel and it scales your image. You do not want the image scaled. If so then make the central widget a QWidget and create a QPainter in it. If you need to draw an image, then "erase background" of the QWidget by QPainter::fillRect() and then draw the image at a given point (it depends on the sizes of the image) by QPainter::drawImage(). You will need QImages instead of QPixmaps now.
Hi Radek,
Thank you for your help. I got this working using the QLabel->resize() function in order to properly display a scaled image.
Bookmarks