Results 1 to 1 of 1

Thread: Text inside QListWidgetItem moving to the left when QIcon is added from the right.

  1. #1
    Join Date
    Mar 2016
    Qt products
    MacOS X Windows

    Question Text inside QListWidgetItem moving to the left when QIcon is added from the right.

    I am working on a application for both Mac and Windows.
    I am using QListwidget to list down few things and I add QListWidgetItem to it.
    Each QListWidgetItem has some text and based on somoe conditions I add a warning Icon to it from the right side to indicate to the user that something has gone wrong.

    Now the problem is only on MAC, whenever I add this Icon from the right side the text moves slightly to the left which doesn't look good. There is enough space for the Icon to be there but still it pushes the text to the left.

    The text alignment is set using:
    setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter | Qt::AlignAbsolute );

    Icon is added and removed using this code:

    void ChangeState( bool inState )
    QIcon icon;
    if( inState )
    QPixmap pixmap("Info_icon.png");
    icon.addPixmap( pixmap, QIcon::Normal, QIcon::On );
    QPixmap pixmap;
    icon.addPixmap( pixmap, QIcon::Normal, QIcon::Off );
    setIcon( icon );

    Does anyone have any solution to stop the movement of Text to the left when ChangeState( true ) is called.

    Please the attachment to get more idea.

Similar Threads

  1. Moving QGraphicsScene to Left or Right firections
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 05:45
  2. Replies: 0
    Last Post: 24th May 2010, 13:19
  3. How to resize the QIcon inside QPushButton dynamically?
    By gboelter in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2010, 13:34
  4. Rich Text Inside QListWidgetItem?
    By Jick in forum Newbie
    Replies: 1
    Last Post: 17th February 2010, 02:30
  5. Moving left and right on the screen
    By Benjamin in forum Qt Programming
    Replies: 6
    Last Post: 21st June 2009, 20:09

Tags for this Thread


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.