Results 1 to 8 of 8

Thread: Size of an Icon

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Size of an Icon

    Hello Friends.
    How can I modify the size of my icon in my QListWidgetItem. I have an png with 128*128

    Qt Code:
    1. QStringList myStringList2;
    2. myStringList2 <<"test";
    3. QIcon testItemIcon(":/images/undo.png");
    4. foreach(QString str2, myStringList2){
    5. QListWidgetItem *testItem = new QListWidgetItem(testItemIcon, str2, customerList);
    6. customerList->addItem(testItem);
    7. QRadialGradient gradient(100, 100, 100, 100, 100);
    8. gradient.setColorAt(0, QColor::fromRgbF(210, 239, 109,0));
    9. gradient.setColorAt(1, QColor::fromRgbF(0, 1, 0, 0));
    10. QBrush brush(gradient);
    11. testItem->setBackground(brush);
    12. }
    To copy to clipboard, switch view to plain text mode 

    but my icon is quit little and i don´t know why??

    Have you some ideas

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Size of an Icon

    QListWidget is a QListView. QListView is a QAbstractItemView. QAbstractItemView has a property iconSize:
    Qt Code:
    1. listWidget->setIconSize(QSize(24, 24));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    embeddedmz (20th May 2021)

  4. #3
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default

    I don´t understand i don´t have a listWidget i have a ListWidgetItem

    and QListWidgetItem have no setIconSize()
    Last edited by wysota; 26th August 2007 at 21:52.

  5. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Size of an Icon

    QAbstractItemView is the base class of QListWidget and it has that method.

    Regards

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Size of an Icon

    QListWidget is a widget where QListWidgetItems are added to. QListWidgetItems are nothing visible until they are added to a QListWidget.

    So what is customerList?
    Qt Code:
    1. customerList->addItem(testItem);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  7. #6
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default

    thank you it rocks ;o)))

    it seems that every beginning is hard but there is a light i can see it ;o)) thanks for ya help friends
    Last edited by wysota; 26th August 2007 at 21:53. Reason: Posts merged. Please edit your original post instead of posting again next time

  8. #7
    Join Date
    Jul 2007
    Posts
    35
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Size of an Icon

    Quote Originally Posted by LordQt View Post
    Qt Code:
    1. QListWidgetItem *testItem = new QListWidgetItem(testItemIcon, str2, customerList);
    2. customerList->addItem(testItem);
    To copy to clipboard, switch view to plain text mode 
    Hi,
    only a little note: it is not needed to use addItem() if you already specified the parent QListWidget in the QListWidgetItem constructor.
    It is not an error, but it is redundant.

    These are a little better ways to do it:
    Qt Code:
    1. // Constructed with the list widget as their parent widget
    2. QListWidgetItem *testItem = new QListWidgetItem(testItemIcon, str2, customerList);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. // Constructed with no parent widget and added to the list later
    2. QListWidgetItem *testItem = new QListWidgetItem(testItemIcon, str2);
    3. customerList->addItem(testItem);
    To copy to clipboard, switch view to plain text mode 

    References:
    QListWidget : http://doc.trolltech.com/4.3/qlistwidget.html#details
    QListWidgetItem : http://doc.trolltech.com/4.3/qlistwi...stWidgetItem-3
    Last edited by iw2nhl; 26th August 2007 at 13:45.

  9. #8
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Size of an Icon

    jes it´s logic thank you for your tip

Similar Threads

  1. QToolBar icon size
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2007, 13:12
  2. Replies: 1
    Last Post: 24th October 2006, 16:40
  3. Difficult:Dynamic Icon size change?!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 10th April 2006, 09:39
  4. tool bar icon size looking small???
    By darpan in forum Qt Tools
    Replies: 7
    Last Post: 31st March 2006, 16:38
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.