Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qlistwidgetitem
    Log in to post

    • UNSOLVED Optimization for Game Launcher, need ideas
      Brainstorm • qlistwidget custom widget qlistwidgetitem ram optimization • • Emrecp  

      2
      0
      Votes
      2
      Posts
      82
      Views

      Resize the icons when loading them into memory - don't store the big ones. Also, use lazy loading (defer loading of icons and items until they are needed), using canFetchMore() and fetchMore() functions of your model.
    • SOLVED Find QListWidgetItem by custom widget object name
      Qt 6 • qlistwidgetitem • • akshaybabloo  

      8
      0
      Votes
      8
      Posts
      117
      Views

      @Christian-Ehrlicher True and this is what I did. It works: void MainWindow::removeItem(const QString &text) { for (int i = 0; i < ui->listWidget->count(); ++i) { auto item = ui->listWidget->item(i); auto itemWidget = dynamic_cast<CustomWidget*>(ui->listWidget->itemWidget(item)); if (itemWidget->getText() == text){ delete item; break; } } }
    • SOLVED How to edit a QListwidgetItem by using custom context menu ? need some corrections
      General and Desktop • c++ qlistwidget qlistwidgetitem context menu • • learnist  

      4
      0
      Votes
      4
      Posts
      108
      Views

      @learnist said in How to edit a QListwidgetItem by using custom context menu ? need some corrections: but for point 3 ,which edit trigger should i use ?? can you please elaborate If you don't want double clicking or any key pressing to trigger the editing, just set it to QAbstractItemView::NoEditTriggers.
    • UNSOLVED Drag and Drop from 2 Listwidgets, but change text after dropping in 2nd Listwidget
      General and Desktop • c++ qt 5.4 qlistwidget drag and drop qlistwidgetitem • • learnist  

      5
      0
      Votes
      5
      Posts
      36
      Views

      Good then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found.
    • UNSOLVED calling QListWidgetItem setText() or setCheckState() on crashes Qt application
      General and Desktop • qt5 qlistwidget qlistwidgetitem qt5.13.1 • • CybeX  

      3
      0
      Votes
      3
      Posts
      116
      Views

      @VRonin Doing a few (rather simple) tests, I found the following (which confirms your suspicion) Works: (but no check box) - this is expected to work // create item QListWidgetItem* item = new QListWidgetItem(name, ui->listDriveInfo); // item->setText(name); // item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item); this crashes on setFlags() call // create item QListWidgetItem* item = new QListWidgetItem(name, ui->listDriveInfo); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item); but these 2 both work (without setting owning QListWidget) // create item QListWidgetItem* item = new QListWidgetItem(name); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item); and // create item QListWidgetItem* item = new QListWidgetItem(); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item); Testing: I create a new application, did exactly the same (add a string and a checkbox) and that work 100%. Create a form, throw on a QListWidget and run it with this code. QListWidgetItem* item = new QListWidgetItem("New", ui->listWidget); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(Qt::Unchecked); QListWidgetItem* item1 = new QListWidgetItem("New 1", ui->listWidget); item1->setFlags(item->flags() | Qt::ItemIsUserCheckable); item1->setCheckState(Qt::Unchecked); QListWidgetItem* item2 = new QListWidgetItem("New 2", ui->listWidget); item2->setFlags(item->flags() | Qt::ItemIsUserCheckable); item2->setCheckState(Qt::Unchecked); ui->listWidget->addItem(item); ui->listWidget->addItem(item1); ui->listWidget->addItem(item2); connect(ui->listWidget, &QListWidget::itemClicked, this, [this](QListWidgetItem * i) { // Get drive info from driveList int pos = ui->listWidget->row(i); // check state & set state bool active = i->checkState() == Qt::Checked; qDebug() << (active ? "enabled" : "disabled"); }); So my question is, bug (on whose side) or some setting on my side? Thoughts on what to look for?
    • SOLVED Is it possible to get last x items (such as 5 items) from QListWidget?
      General and Desktop • qlistwidget qlistwidgetitem • • R_Irudezu  

      6
      0
      Votes
      6
      Posts
      642
      Views

      @Ratzz Sorry i can not check your answer as solved answer, Qt forum has a bug about that. I solved my problem, i've already read the topic that you linked here but after you posted it then a read again and i solved my problem thank you, but even so trying to give more explanatory answers is a good way because i like this forum and i want to see answers from another angles, another perspectives. When i get experienced at Qt i want to give good answers too. :) And thank you so much Mr. @dheerendra . I think approach with row is a better way but i was need to a quick way so that stackoverflow link helped me about that.
    • UNSOLVED Animating the QListWidgetItem objects within the QListWidget
      General and Desktop • qlistwidget qobject animation qlistwidgetitem • • philm001  

      8
      0
      Votes
      8
      Posts
      1201
      Views

      @philm001 the stylesheet declaration should rather look like this i guess: w->setStyleSheet(QString("QListView::item { background: rgba(255, 0, 0, %1)}").arg(value.toInt())
    • SOLVED How to update QListWidgetItem geometry.
      General and Desktop • qwidget qlistwidget qlistwidgetitem geometry • • tokafr  

      5
      0
      Votes
      5
      Posts
      2861
      Views

      Well seems that it needs to emit model's layoutChanged() to do what I need. I created new class which inherits QListWidget and there I connected signal to layoutChanged signal of model() object and it worked.
    • UNSOLVED QListWidget delete selected item
      General and Desktop • qlistwidget delete qlistwidgetitem removerow delete row • • testerius  

      7
      0
      Votes
      7
      Posts
      15528
      Views

      @kishore_hemmady said in QListWidget delete selected item: how can i achieve this by selecting the check Box rather than selecting the list content? for(int i=ui->listWidget->model()->rowCount()-1;i>=0;--i){ if(ui->listWidget->model()->index(i,0).data(Qt::CheckStateRole).toInt()==Qt::Checked) ui->listWidgetMy->model()->removeRow(i); }
    • UNSOLVED QListWidgtem(Item) parent and child
      General and Desktop • parent qlistwidgetitem child • • Meugiwara  

      7
      0
      Votes
      7
      Posts
      2452
      Views

      @VRonin Oh and you provide a model based solution. Much more elegant :) https://forum.qt.io/topic/72974/link-two-qlistwidget/4
    • SOLVED QListWidget with dynamic icons
      General and Desktop • qlistwidget icon qlistwidgetitem • • Harry123  

      12
      0
      Votes
      12
      Posts
      4090
      Views

      It's good when it's more friendly :)
    • UNSOLVED QListWidgetItem several pieces of information
      General and Desktop • qlistwidgetitem • • WhatIf  

      2
      0
      Votes
      2
      Posts
      626
      Views

      @WhatIf Can someone show me an example of what other pieces of information it can hold? What type? Any type that's registered for QVariant (declared as a meta-type). Here's what Qt has a data roles, but you can have your own. Kind regards.
    • SOLVED Long press event for QListWidget
      Mobile and Embedded • android qlistwidget touch qlistwidgetitem • • mbnoimi  

      2
      0
      Votes
      2
      Posts
      1430
      Views

      I fixed this issue depending on the mentioned snippet here: http://www.qtcentre.org/threads/53580-TapAndHoldGesture-sender-object-name
    • UNSOLVED QListWidgetItem is not being selected
      General and Desktop • qlistwidget pyqt4 qlistwidgetitem list • • Streakflash  

      2
      0
      Votes
      2
      Posts
      931
      Views

      Hi, Why not use the parameters of currentItemChanged to get the current item ?
    • Resize a QListWidgetItem with a custom QAbstractItemDelegate when it's clicked
      General and Desktop • resize qt 5.4.1 qlistwidgetitem qabstractitemde • • DaMaxx  

      4
      0
      Votes
      4
      Posts
      1314
      Views

      Then you should also implement the sizeHint method of your delegate
    • [Solved]Select QListWidgetItem with css property selector.
      General and Desktop • qlistwidget css qlistwidgetitem icons selectors • • Socapex  

      7
      0
      Votes
      7
      Posts
      4904
      Views

      For that kind of things the combo: QListView QStringListModel QIdentityProxyModel << Customize the icons here would do it in a simpler way. As for items being QObject derived classes, rather not. The various QXXXItem classes must be as lightweight as possible since there can be several thousands of them and QObject has a cost and constraints. Except maybe in a few corner cases there would be no real benefit to have it there for the common usage.