Results 1 to 3 of 3

Thread: QListWidget: widget sometime can't alignment to baseline.

  1. #1
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QListWidget: widget sometime can't alignment to baseline.

    Hi all
    I use a QListWidget to show a custom widgets that include a label and checkbox.
    But sometimes, these custom widgets didn't alignment to a baseline, like blow picture
    qlistwidget_align_issue.jpg

    And you can see there is a light-blue block above the widget that doesn't align.
    here is the code i insert the custom widget to qlistwidget

    CustomWidget*cgv = new CustomWidget();

    cgv->setChecked(cellPassed[j].checked); // set checkbox state
    cgv->setImage(QPixmap::fromImage(qimg)); // set the image show by QLabel

    QString itemName = "block" + QString::number(i); // assign a name to the item to search it by name.
    QListWidgetItem *item = new QListWidgetItem(itemName, ui->listWidget);

    ui->listWidget->addItem(item);
    item->setSizeHint(cgv->size());
    ui->listWidget->setItemWidget(item, cgv); // insert the custom widget to the current item.

    I try to set Qlistwidget's resize mode to batched and set batchsize to 1, it looks work for this issue,
    but batchsize 1 is not good for display while resize the QListWidget content.

    does anyone have any comment for this issue?
    thanks a lot.

    BR, Titan.Chen

  2. #2
    Join Date
    Sep 2006
    Posts
    38
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QListWidget: widget sometime can't alignment to baseline.

    What are you using in the UI to display the list widget?

  3. #3
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListWidget: widget sometime can't alignment to baseline.

    Hi
    I use QT's designer form to create the ui.

Similar Threads

  1. Text Alignment in QMainWindow Widget
    By GTBuilder in forum Newbie
    Replies: 2
    Last Post: 9th February 2012, 12:30
  2. Replies: 0
    Last Post: 24th October 2011, 12:52
  3. Setting widget alignment
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2008, 07:48
  4. question about text alignment in QListWidget
    By to_guliang in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2008, 11:04
  5. Widget alignment.
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2007, 19:09

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.