Skip to content
  • 0 Votes
    5 Posts
    2k Views
    T

    @KroMignon

    Thanks for the extensive explanation!
    Now I understand what I was doing wrong.

    Kind regards

  • 0 Votes
    10 Posts
    5k Views
    mrjjM

    @Christian-Ehrlicher
    ahh, you are right. Good catch.
    http://doc.qt.io/qt-5/qjsonvalue.html#toDouble
    converts the QJsonValue to double if its that type().
    in this case it will return defaultValue (0)

    so its something like

    QJsonValue bid1 = jsonObj.value("bid_1"); QString asStr=bid1.toString(); double n = asStr.toDouble(); qDebug() << n;
  • 0 Votes
    8 Posts
    5k Views
    VRoninV

    This is strange. could you try if this snippet works for you?

    #include <QApplication> #include <QWidget> #include <QVBoxLayout> #include <QPushButton> #include <QTableWidget> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget mainWid; QStringList changedValues; QVBoxLayout* mainLay=new QVBoxLayout(&mainWid); QTableWidget* tableWidget = new QTableWidget(&mainWid); QPushButton* button = new QPushButton(QStringLiteral("Display list"),&mainWid); QLabel* resultLabel = new QLabel(&mainWid); mainLay->addWidget(tableWidget); mainLay->addWidget(button ); mainLay->addWidget(resultLabel ); tableWidget->setColumnCount(1); tableWidget->setRowCount(5); for(int i=0;i<5;i++){ QTableWidgetItem* const newItem= new QTableWidgetItem; newItem->setData(Qt::EditRole,i); tableWidget->setItem(i,0,newItem); } QObject::connect(tableWidget,&QTableWidget::cellChanged,[&changedValues,tableWidget](int row, int column)->void{changedValues<<tableWidget->item(row,column)->text();}); QObject::connect(button ,&QPushButton::clicked,[&changedValues,resultLabel ]()->void{resultLabel->setText(changedValues.join(','));}); mainWid.show(); return a.exec(); }
  • 0 Votes
    5 Posts
    3k Views
    VRoninV

    Then even easier to use 1 QSqlQueryModel or QSqlTableModel

  • 0 Votes
    3 Posts
    902 Views
    K

    @J.Hilk Thanx alot

  • 0 Votes
    9 Posts
    3k Views
    jsulmJ

    @ForestPoem In the slot you know which signal was emitted (the one you connected it to), you can even get the pointer to the object which emitted the signal using sender()

  • 0 Votes
    4 Posts
    4k Views
    A

    How do you construct comboboxes?
    Do you assign it to the cell with QTableWidget ::setCellWidget?

    If yes these combo boxes are completely independent widgets unrelated to QTableWidget.
    So no itemChanged or any other table related signal is going to be sent when you manipulate with cell widget (unless you do it yourself).
    In reality using cell widgets screw your table view navigation and selection.

    I would highly recommend to avoid cell widget approach and leave it only for very simple cases.
    In your case it probably would be better to use column specific delegates.

    Recommendations from the top of my head:

    find is a Spin Box Delegate example in documentation. Make your own subclass similar to in example. set autoFillBackground(true) to your editor widget in the createEditor method. Set openPersistentEditor on your view's for desired rows/columns.