Results 1 to 11 of 11

Thread: Custom Items for QListWidget

  1. #1
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Custom Items for QListWidget

    As I understood from reading meny threads, I have to create a custom widget, that i will be able to use as Items for QListWidget is that correct?
    If it is, could u give me some links or describe how to create your own/custom widgets?
    Sorry for noob question.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Items for QListWidget

    I have to create a custom widget, that i will be able to use as Items for QListWidget is that correct?
    It depends on what your needs are.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom Items for QListWidget

    I need a list of items, where each item consists of a label and 4 buttons.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Items for QListWidget

    If it is, could u give me some links or describe how to create your own/custom widgets?
    Then yes, you will need to create a custom widget.

    If it is, could u give me some links or describe how to create your own/custom widgets?
    Nothing special about it.
    You just subclass the appropriate widget class and add the other widgets as members.
    This is basic C++ stuff.
    If you know how to subclass, you know how to create custom widgets.
    Unless you mean with your question something more specific - in that case please elaborate.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom Items for QListWidget

    Quote Originally Posted by high_flyer View Post
    just subclass the appropriate widget class and add the other widgets as members.
    Which would be the appropriate widget class in this situation?

    Turns out i'll need a picture to... How to add a picture to mine custom widget?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Items for QListWidget

    Which would be the appropriate widget class in this situation?
    I would use a QWidget, since there is no functionality you need to subclass, except it being a widget.
    But QLabel or QFrame would also work.
    you can have a look how a custom widget is done here:
    http://doc.trolltech.com/4.7/designe...m-widgets.html

    This is more about how to create a designer plugin, but part of it is creating a custom widget, which you can look at.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom Items for QListWidget

    Quote Originally Posted by high_flyer View Post
    I would use a QWidget, since there is no functionality you need to subclass, except it being a widget.
    But QLabel or QFrame would also work.
    you can have a look how a custom widget is done here:
    http://doc.trolltech.com/4.7/designe...m-widgets.html

    This is more about how to create a designer plugin, but part of it is creating a custom widget, which you can look at.
    Thanks! But what about the picture?

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Items for QListWidget

    What about it?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #9
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom Items for QListWidget

    which widget should i use to add a picture to mine customized widget?

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Items for QListWidget

    Well, how about you first read the docs a bit?
    And also look at the links in my previous post in this thread.
    There most of the information you are asking about is there.
    If you encounter problems or need further help you are welcome to ask again.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom Items for QListWidget

    Hm.. Every thread and every link I look - I can't find step by step walhthrough on how to create youw own widget. Which option should I select in create new project?


    Added after 1 4 minutes:


    OK, somehow i got around that just merging those 2 files into mine project.
    Now i have a different kind of problem - how can i resize QListWidget elements? I want to make all of them to be constant, but bigger size that they are now...


    Added after 7 minutes:


    OK, i was able to resolve that problem as well (setSizeHint(QSize(xx, xx)).
    Thanks for help!
    Last edited by Archa4; 2nd February 2011 at 12:51.

Similar Threads

  1. Move items up and down in QListWidget
    By araglin in forum Newbie
    Replies: 7
    Last Post: 31st August 2016, 11:05
  2. remove all items from QListWidget
    By GrahamLabdon in forum Newbie
    Replies: 1
    Last Post: 19th January 2011, 16:35
  3. add custom widget items to QListView or QListWidget
    By yazwas in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2010, 22:36
  4. QListWidget cannot handle too many items
    By mr.hichem in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 23:00
  5. Getting all items of a QListWidget
    By Codepoet in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2006, 22:52

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.