Navigation

    Qt Forum

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

    • SOLVED How to manually activate CheckBox blue focus indicator ?
      QML and Qt Quick • qml quick checkbox quick controls • • Mixlu  

      2
      0
      Votes
      2
      Posts
      12
      Views

      Problem solved by calling chekbox.forceActiveFocus(Qt.TabFocusReason)
    • SOLVED onCheckedChanged vs onCheckStateChanged
      General and Desktop • checkbox • • chilarai  

      3
      0
      Votes
      3
      Posts
      53
      Views

      @KroMignon Thanks
    • UNSOLVED QTreeView & QStyledItemDelegate & QPushButton/Checkbox etc?
      General and Desktop • qtreeview qpushbutton qstyleditemdele checkbox • • Dariusz  

      20
      0
      Votes
      20
      Posts
      3141
      Views

      Hey Got a follow up question in regards to styling... How can I get QComboBox focus indicator/rect ? So that I can set correct color for the outline of comboBox to paint? I tried using QRect r = QApplication::style()->subElementRect(QStyle::SE_ComboBoxLayoutItem, &option, mWidgetList[ComboBox]); and QRect r = QApplication::style()->subElementRect(QStyle::SE_ComboBoxFocusRect, &option, mWidgetList[ComboBox]); But neither return correct rect to use as paint target... Only the large square one around item in tree view. Any hints? Same for QPushButton, and pretty much any button/combo like widget I think o.O TIA.
    • UNSOLVED How to add QCheckBox to column and make model appear in QTreeView.
      General and Desktop • checkbox modelview itemmodel • • SRaD  

      6
      0
      Votes
      6
      Posts
      990
      Views

      I'm sorry but I don't think will compile. Please provide a minimal, compilable example which shows your problem. E.g int main (int argc, char **argv) { QApplication app(argc, argv); QTreeWidget treeWidget; QTreeWidgetItem *cities = new QTreeWidgetItem(&treeWidget); cities->setText(0, "Cities"); treeWidget.show(); return app.exec(); } See http://doc.qt.io/qt-5/qtreewidgetitem.html#details
    • SOLVED Configuring checkbox when using QTreeWidget
      General and Desktop • pyqt5 qtreewidget checkbox • • MATTK  

      4
      0
      Votes
      4
      Posts
      4931
      Views

      @MATTK said in Configuring checkbox when using QTreeWidget: is this a bug or a known issue from Qt Designer? No, it's 100% intended behaviour. the condition is checked here You have 2 options: set the Qt::CheckStateRole for the indexes you want to have a checkbox. In your widget constructor you'd call something like setUnchecked(ui->treeWidget->model()); void setUnchecked(QAbstractItemModel* model, const QModelIndex& parent = QModelIndex()){ if(!model) return; for(int i=0, maxRow=model->rowCount(parent);i<maxRow;++i){ for(int j=0, maxCol=model->columnCount(parent);j<maxCol;++j){ const QModelIndex currIdx = model->index(i,j,parent); model->setData(currIdx,Qt::Unchecked,Qt::CheckStateRole); if(model->hasChildren(currIdx)) setUnchecked(model,currIdx); } } } subclass the delegate to check the flag instead of Qt::CheckStateRole and call something like ui->treeWidget->setItemDelegate(new CheckFlagDelegate(this)); in your widget constructor class CheckFlagDelegate : public QStyledItemDelegate{ Q_OBJECT Q_DISABLE_COPY(CheckFlagDelegate) public: explicit CheckFlagDelegate(QObject* parent = Q_NULLPTR) : QStyledItemDelegate(parent){} protected: void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const Q_DECL_OVERRIDE{ QStyledItemDelegate::initStyleOption(option,index); if(index.model()->flags(index) & Qt::ItemIsUserCheckable) option->features |= QStyleOptionViewItem::HasCheckIndicator; } }; Since the functionality is defined in a QObject (the delegate) and not in a QWidget this is not something designer can and probably ever will manage
    • UNSOLVED CheckBox to QInputDialog..?
      General and Desktop • dialog checkbox qinputdialog • • Rohith  

      2
      0
      Votes
      2
      Posts
      986
      Views

      @Rohith no it's not. You would have to implement your custom QDialog subclass. Which shouldn't be much of an effort.
    • UNSOLVED Dodanie kolumny z checkboxem do QTableView
      Polish • qtableview checkbox qsqlquerymodel • • drock  

      2
      0
      Votes
      2
      Posts
      1127
      Views

      Można użyć modelu proxy, który będzie interpretował jakieś dane (np. "0" i "1") jako checkbox, np. class MyProxy : public QIdentityProxyModel { public: MyProxy(QObject* parent) : QIdentityProxyModel(parent) {} QVariant data(const QModelIndex& index, int role) const override { if (role == Qt::CheckStateRole && index.column() == 0) { QString str_value = QIdentityProxyModel::data(index, Qt::DisplayRole).toString(); return (str_value == "1") ? Qt::Checked : Qt::Unchecked; } return QIdentityProxyModel::data(index, role); } bool setData(const QModelIndex& index, const QVariant& value, int role) override { if (role == Qt::CheckStateRole && index.column() == 0) { QString str_value = (value.toInt() == Qt::Checked) ? "1" : "0"; return QIdentityProxyModel::setData(index, str_value, Qt::EditRole); } else return QIdentityProxyModel::setData(index, value, role); } Qt::ItemFlags flags(const QModelIndex& index) const override { Qt::ItemFlags f = QIdentityProxyModel::flags(index); if (index.column() == 0) f |= Qt::ItemIsUserCheckable; return f; } }; oczywiście numer kolumny i dane rozpoznawane jako "zaznaczony" można sobie dostosować. Takiego modelu można użyć potem tak: QSqlTableModel* model = new QSqlTableModel(parent, database); MyProxy* proxy = new MyProxy(parent); proxy->setSourceModel(model); tableView->setModel(proxy);
    • SOLVED TableView with CheckBox in header
      QML and Qt Quick • qml checkbox tablview • • PhTe  

      6
      0
      Votes
      6
      Posts
      3073
      Views

      @medyakovvit Yeah, that woks. Thanks :)
    • UNSOLVED ComboBox Of CheckBoxes not working in Qt5
      General and Desktop • checkbox combobox model • • Fahad Al-Saidi  

      5
      0
      Votes
      5
      Posts
      2102
      Views

      @Devopia53 Thanks, the checkboxes are displayed at least but selection by mouse is very difficult. I don't know why. UPDATE I comment out li->flags() and things works fine.
    • UNSOLVED checkbox column in tableview
      General and Desktop • delegate checkbox column • • Bazelboday  

      1
      0
      Votes
      1
      Posts
      2196
      Views

      No one has replied

    • SOLVED How To Add Select All Checkbox in QTableWidget QHeaderView
      General and Desktop • qtablewidget qheaderview checkbox select all • • maximo  

      3
      0
      Votes
      3
      Posts
      9380
      Views

      @maximo Hi It creates a new Header that draws a check box image on itself since its not possible to insert a real widget. It then response to mouse press to make the image work as a real check box. it checks with if (logicalIndex == 0) so I think it only paints this in first column.
    • How to customize a QFileDialog with checkboxes
      General and Desktop • qfiledialog checkbox customize • • bereid  

      1
      0
      Votes
      1
      Posts
      946
      Views

      No one has replied

    • How to check the state of a checkbox when a button is clicked.
      General and Desktop • checkbox messagebox • • alchemydragon  

      9
      0
      Votes
      9
      Posts
      5849
      Views

      @Brad-M I made it in Designer. I double checked the id box. It has ckbox. Sorry I am just now getting back to you. It has been busy at work this week.
    • QAbstractListModel checkbox list exclusive
      QML and Qt Quick • qabstractlistmo checkbox • • Erakis  

      3
      0
      Votes
      3
      Posts
      1956
      Views

      Hi try to use Binding to your CheckBox: Binding { target: checkbox property: 'checked' value: checkboxenable } where checkboxenable is role in your model
    • Setting background color for QCheckBox::indicator resets all other styling
      General and Desktop • stylesheet checkbox • • Jakob  

      2
      0
      Votes
      2
      Posts
      1340
      Views

      Hi, Nothing really wrong, QWidget using style sheets are rendered by a special style. With style sheets you can customize things that might not be done with the native style.
    • Using checkable QStandardItems in a ListView.
      General and Desktop • listview checkbox qstandarditems • • ealione  

      15
      0
      Votes
      15
      Posts
      4545
      Views

      No there is not at the moment. But as I said earlier this was based on some code from here. I tested it too, and if you try to add checkboxes just in the way I have done in the code above and compile, you can clearly see what I am talking about. Just make sure you browse to a folder that contains only images of the dimensions I specified.
    • Style checkbox for a QStandardItem.
      General and Desktop • stylesheet qstandarditem checkbox • • ealione  

      5
      0
      Votes
      5
      Posts
      2314
      Views

      use this QComboBox QAbstractItemView { selection-background-color: lightgray; } QAbstractItemView::indicator { background-color: rgb(0, 255, 0); width :20; height :20; } QAbstractItemView::indicator:checked { background-color: rgb(255, 170, 0); }
    • QStyledItemDelegate - strange behavior of checkbox
      General and Desktop • model-view delegate checkbox • • dis  

      2
      0
      Votes
      2
      Posts
      1191
      Views

      Hi and welcome to devnet, Since you are painting things yourself, you would also need to handle the mouse interaction yourself. Painting a QCheckBox is not the same has having an actual checkbox widget.