Results 1 to 19 of 19

Thread: Design User Interface using QT - Help needed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Design User Interface using QT - Help needed

    (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:
    1. QPixmap imgPixmap(fileNamePics);
    2. QIcon imgIcon(imgPixmap.scaled(100,80));
    3.  
    4. ui.PushButtonUp->setIcon(imgIcon);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2014
    Location
    Dubai
    Posts
    2
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Re: Design User Interface using QT - Help needed

    Hallo everyone,
    I like this form, place tell me why use design QT ?
    thank,s

  3. #3
    Join Date
    Feb 2014
    Location
    Romania
    Posts
    25
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Design User Interface using QT - Help needed

    Quote Originally Posted by Radek View Post
    (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:
    1. QPixmap imgPixmap(fileNamePics);
    2. QIcon imgIcon(imgPixmap.scaled(100,80));
    3.  
    4. ui.PushButtonUp->setIcon(imgIcon);
    To copy to clipboard, switch view to plain text mode 
    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?

  4. #4
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Design User Interface using QT - Help needed

    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.

  5. #5
    Join Date
    Feb 2014
    Location
    Romania
    Posts
    25
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Design User Interface using QT - Help needed

    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
    Qt Code:
    1. QStringList listaPics = QFileDialog::getOpenFileNames(this, tr("Open File"),
    2. "E:\\Personal\\TestImageLoaderQt",
    3. tr("Images (*.jpg"));
    4.  
    5. //get the pixList
    6. for(int i = 0; i < listaPics.size(); i ++)
    7. {
    8. QPixmap imgPixmap (listaPics[i]);
    9. pixList.append(imgPixmap);
    10. }
    11.  
    12. for (int i = 0; i < pixList.size(); ++i)
    13. {
    14. QPixmap pix(pixList[i]);
    15.  
    16. QIcon *iconImage = new QIcon(pix);
    17.  
    18. QListWidgetItem *listWindgetItemImage = new QListWidgetItem;
    19. listWindgetItemImage->setIcon(*iconImage);
    20.  
    21. ui.listWidgetImage->addItem(listWindgetItemImage);
    22. ui.listWidgetImage->setIconSize(QSize(70, 80));
    23. }
    To copy to clipboard, switch view to plain text mode 
    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).
    Have any tips about this?

  6. #6
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Design User Interface using QT - Help needed

    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.

  7. #7
    Join Date
    Feb 2014
    Location
    Romania
    Posts
    25
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Design User Interface using QT - Help needed

    Hi Radek,

    Thank you for your help. I got this working using the QLabel->resize() function in order to properly display a scaled image.

Similar Threads

  1. User Interface Ontology as a way to guide Qt GUI design
    By Nathaniel Christen in forum General Discussion
    Replies: 7
    Last Post: 16th June 2011, 18:06
  2. design help with QList in an interface
    By GuusDavidson in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2011, 07:05
  3. Replies: 5
    Last Post: 28th May 2010, 16:28
  4. Problem with design interface
    By tux-world in forum Newbie
    Replies: 5
    Last Post: 10th March 2010, 14:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.