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
    Feb 2014
    Location
    Romania
    Posts
    25
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Design User Interface using QT - Help needed

    Hello all,

    First of all I apologize if this subject has been already debated on the forums, but I couldn't find anything to solve my issue.

    I am using the Visual 2010 Add-In for Qt(Qt Vs. 5.2.0). I want to have something similar to this(click on the below image so you can have a better view about this).
    QT_UI.jpg

    So, as you can see I have a label where I display about three pics. These pics are loaded from a given directory.
    I want to be able to load multiple image from the directory but only display three and move through the image list with those buttons(Up and Down). When I load these images, a current image can be selected to be displayed as a preview.

    This is my desired behavior.

    What I don't know.

    What to choose to display the related images from the image list. I've used a QWidget where multiple QLabel have been added. Each label is used to display a image. However, I can't trigger an action in order to be able to have a preview of a given image(currently I'm using a click() Preview button to set the preview of the first image from my list). So, this is not seems to be a good approach.

    I read multiple articles about QGraphicsView and QGraphicsScene and this seeems what I have to use. Unfortunately I am not able to make this working.
    I don't know how to implement that, to display those three images and navigate between the image list with Up and Down button.

    I would be gratefully if you can share these knowledge with me and all the QT users.

    So, how to load multiple images, display only some of them(about 3 of them) in a label, be able to navigate through the image list and be able to display one image from those three as a preview image. Just sent a signal when I select a picture and set the image in the preview label.

    If you need more details from me, please do not hesitate to ask.

    Thanks a lot,
    Danny

  2. #2
    Join Date
    Oct 2013
    Posts
    41
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Design User Interface using QT - Help needed

    Well I haven't worked a lot with images, but it looks like the easy thing to do would be to turn your QLabels into QPushButtons and use the image as the QIcon for the button.

  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 sulliwk06 View Post
    Well I haven't worked a lot with images, but it looks like the easy thing to do would be to turn your QLabels into QPushButtons and use the image as the QIcon for the button.
    Thank you! Indeed, this can be the easy approach. I didn't tried this yet so I can't tell you how it would look like.

    However, I am still waiting for someone who can give me a reply with related guidance for using QGraphicsView and QGraphicsScene, and how it would look like this approach.

  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

    I recommend QToolButton class. The class is intended for toolbars but it is a fully functional "bitmap button" which can display a QIcon without a text. Therefore, 2 QPushButtons with 3 QToolButtons in between and QPixmap (or QImage) to the right. If you click Up or Down, redo the icons. When you click a QToolButton, redo the image.

    As to devising the GUI: set sizes of the button and the QIcon, remove text and set style to QToolButtonIconOnly in the Designer.

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Design User Interface using QT - Help needed

    So, how to load multiple images, display only some of them(about 3 of them) in a label, be able to navigate through the image list and be able to display one image from those three as a preview image. Just sent a signal when I select a picture and set the image in the preview label.
    You could also try for QListWidget / QListView with iconView. You can click the items aka images and do the desired operation. If you fix the grid size of list widget, you may be able to limit the images to three as desired. On button click , you can simply change the current index of the listWidget OR move the scroll bars ...
    Also you can have a model with QListWidget which will load images from a given directory which will again ease ur work

  6. #6
    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 all,

    Thank you for the valuable information. You give me a starting point. I've just get back to work and I'll let you know how things go.

    As soon as I have something working I'll share with you.

    Thanks,
    Danny

  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 all,

    I'm afraid I can't add a QPixmap as a QlistWidget item. Here's what I've tried:
    Qt Code:
    1. QString fileNamePics = QFileDialog::getOpenFileName(this, tr("Open File"),
    2. "E:\\Personal\\TestImageLoaderQt",
    3. tr("Images (*.jpg"));
    4.  
    5. QPixmap imgPixmap (fileNamePics);
    6.  
    7. QIcon imgIcon(imgPixmap);
    8.  
    9. myListWidget->setViewMode(QListView::IconMode);
    10.  
    11. QListWidgetItem *LWidgetItem = new QListWidgetItem(imgIcon, "Image Name", myListWidget,0);
    12.  
    13. ui.myListWidget->insertItem(1, LWidgetItem);
    To copy to clipboard, switch view to plain text mode 
    Unfortunately, nothing is displayed.

  8. #8
    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

    Yes, it is not.

    (1) If you specify the parent in the QListWidgetItem ctor (it must be a QListWidget *), the item will be added to the parent widget. The widget becomes the owner of the item. Therefore, adding the widget again using QListWidget::insertItem() is wrong. Comment out the insertItem() line and see.

    (2) You gain more flexibility, if you create "stand alone" items, which you add to the widget subsequently by addItem()/insertItem(). Therefore:
    Qt Code:
    1. QListWidgetItem *LWidgetItem = new QListWidgetItem(imgIcon, "Image Name");
    2. ui.myListWidget->insertItem(0, LWidgetItem);
    To copy to clipboard, switch view to plain text mode 

    Note also, that rows are numbered from zero and that you can insert only before an existing item. Adding an item into an empty widget: either add or insert at position 0. Anyway, I don't think you get what you want. You get an "icon view" of a list widget rather than bitmap buttons.

  9. #9

    Default Re: Design User Interface using QT - Help needed

    I propose QToolButton type. This type is supposed for toolbars however this is a thoroughly well-designed "bitmap button" which will show a QIcon with no textual content. Therefore, 3 QPushButtons along with 3 QToolButtons between as well as QPixmap (or QImage) for the correct. Should you just click In place or maybe Straight down, redo the icons. Once you just click a QToolButton, redo the impression.

  10. #10
    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 nengtyas View Post
    I propose QToolButton type. This type is supposed for toolbars however this is a thoroughly well-designed "bitmap button" which will show a QIcon with no textual content. Therefore, 3 QPushButtons along with 3 QToolButtons between as well as QPixmap (or QImage) for the correct. Should you just click In place or maybe Straight down, redo the icons. Once you just click a QToolButton, redo the impression.
    Thank you all for the help. Unfortunately, I can't get this working as I need. I can't get it working at all.
    Can you please write a few lines of code in order to get a starting point?


    Added after 15 minutes:


    What is the container for my QToolButton? How can I add it?
    Last edited by nimrod1989; 16th March 2014 at 19:44.

  11. #11
    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

    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.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.