Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Overloaded function type error

Overloaded function type error

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 5 Posters 8.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #13

    Then there's no need for a "do-it-all" delegate.

    Assign your delegate only to the column where it make sense. That will simplify your life.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    G 1 Reply Last reply
    0
    • SGaistS SGaist

      Then there's no need for a "do-it-all" delegate.

      Assign your delegate only to the column where it make sense. That will simplify your life.

      G Offline
      G Offline
      gabor53
      wrote on last edited by
      #14

      @SGaist
      Which is the better: to have a separate delegate for each column where needed or have one delegate for each type of input method ? (For example one delegate handles all dropdowns, one all check idea etc.)
      Thank you.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #15

        You only need as many delegate as you have special cases.

        Note that I didn't say "as many as the column count". If you have several columns of a special type then juste instantiate one delegate per column.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        G 1 Reply Last reply
        0
        • SGaistS SGaist

          You only need as many delegate as you have special cases.

          Note that I didn't say "as many as the column count". If you have several columns of a special type then juste instantiate one delegate per column.

          G Offline
          G Offline
          gabor53
          wrote on last edited by
          #16

          @SGaist
          How can I use the model directly to save the newly picked image? Is there a sample code you know about?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #17

            Well, you have a pointer to your model in setModelData, so why not use it ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            G 1 Reply Last reply
            0
            • SGaistS SGaist

              Well, you have a pointer to your model in setModelData, so why not use it ?

              G Offline
              G Offline
              gabor53
              wrote on last edited by
              #18

              @SGaist
              I started to use the pointer in setModelData. Added

              oid ImageDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const {
                ImagePickButton* imgPick = qobject_cast<ImagePickButton*>(editor);
                Q_ASSERT(imgPick);
              
                if(imgPick->selectedFile().isEmpty()) {
                  model->setData(index, QVariant(), Qt::UserRole);
                  model->setData(index, QVariant(), Qt::DecorationRole);
                } else {
                  model->setData(index, imgPick->selectedFile(), Qt::UserRole);
                  model->setData(index, QIcon(imgPick->selectedFile()), Qt::DecorationRole);
                  //Adding image to db
              
                  qDebug() << "Selected file: " << imgPick->selectedFile();
                  qDebug() << "Selected file name: " << imgPick->m_selectedFile;
              //new
                  model->setData (index, imgPick->selectedFile (), Qt::DecorationRole);
                }
              

              Causes no error, but doesn't save the img to the db ether. What am I supposed to use to commit the changes to the db?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #19

                What kind of model are you using ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply
                0
                • SGaistS SGaist

                  What kind of model are you using ?

                  G Offline
                  G Offline
                  gabor53
                  wrote on last edited by
                  #20

                  @SGaist
                  I use QStandardItemModel.

                  #include "fixdb.h"
                  #include "ui_fixdb.h"
                  #include <QDebug>
                  
                  FixDb::FixDb(QWidget* parent) :
                    QDialog(parent),
                    ui(new Ui::FixDb) {
                    ui->setupUi(this);
                  
                    correctFriend ();
                  }
                  
                  FixDb::~FixDb() {
                    delete ui;
                  }
                  
                  void FixDb::correctFriend() {
                    QSqlQuery query_fix ("SELECT * FROM Items ORDER BY name asc");
                  
                    if(query_fix.isActive () == true) {
                      qDebug() << "The query_fix is active!";
                    } else {
                      qDebug() << "The query_fix is NOT active!" << query_fix.lastError ();
                    }
                  
                    QStandardItemModel* fixModel = new QStandardItemModel(this);
                    ui->tableView_Fix->setModel (fixModel);
                  
                  
                    ui->tableView_Fix->setItemDelegateForColumn(3, new ImageDelegate(this));
                  
                  
                    for(int row1 = 0; query_fix.next (); row1++) {
                      if(row1 == 0) {
                        const QSqlRecord qRec = query_fix.record();
                        qDebug() << "The number of records (MainWindow): " << qRec;
                        fixModel->insertColumns (0, qRec.count());
                        qDebug() << "fixdb record count: " << qRec.count ();
                  
                      }
                  
                      fixModel->insertRow (row1);
                      fixModel->setData (fixModel->index (row1, 0), query_fix.value (0));
                      fixModel->setData (fixModel->index (row1, 1), query_fix.value (1));
                      fixModel->setData (fixModel->index (row1, 2), query_fix.value (11));
                  
                      fixPixmap.loadFromData (query_fix.value (2).toByteArray ());
                      fixPixmap = fixPixmap.scaled (100, 100, Qt::KeepAspectRatio);
                  
                      fixModel->setData (fixModel->index (row1, 3), fixPixmap, Qt::DecorationRole);
                      fixModel->setData (fixModel->index (row1, 4), query_fix.value (11));
                      fixModel->setData (fixModel->index (row1, 5), query_fix.value (10));
                      fixModel->setData (fixModel->index (row1, 6), query_fix.value (3));
                      fixModel->setData (fixModel->index(row1, 7), query_fix.value (4));
                      fixModel->setData (fixModel->index (row1, 8), query_fix.value (12));
                      fixModel->setData (fixModel->index (row1, 9), query_fix.value (7));
                      fixModel->setData (fixModel->index (row1, 10), query_fix.value (8));
                      fixModel->setData (fixModel->index (row1, 11), query_fix.value (9));
                  
                      ui->tableView_Fix->setRowHeight (row1, 100);
                    }
                  
                    ui->tableView_Fix->horizontalHeader ()->setStyleSheet ("QHeaderView{font: 14pt Arial; color: blue; font-weight: bold; text-decoration: underline;}");
                    ui->tableView_Fix->verticalHeader ()->setVisible (false);
                    ui->tableView_Fix->setAlternatingRowColors (true);
                    ui->tableView_Fix->setStyleSheet ("alternate-background-color: rgb(224,255,248); background-color: white; font: 14pt Arial; ");
                  
                    fixModel->setHeaderData (0, Qt::Horizontal, QObject::tr ("ID"));
                    fixModel->setHeaderData (1, Qt::Horizontal, QObject::tr ("Name"));
                    fixModel->setHeaderData (2, Qt::Horizontal, QObject::tr ("What"));
                    fixModel->setHeaderData (3, Qt::Horizontal, QObject::tr ("Image"));
                    fixModel->setHeaderData (4, Qt::Horizontal, QObject::tr ("Material"));
                    fixModel->setHeaderData (5, Qt::Horizontal, QObject::tr ("Color"));
                    fixModel->setHeaderData (6, Qt::Horizontal, QObject::tr ("Description"));
                    fixModel->setHeaderData (7, Qt::Horizontal, QObject::tr ("Adoption Date"));
                    fixModel->setHeaderData (8, Qt::Horizontal, QObject::tr ("Signed by"));
                    fixModel->setHeaderData (9, Qt::Horizontal, QObject::tr ("History"));
                    fixModel->setHeaderData (10, Qt::Horizontal, QObject::tr ("Age"));
                    fixModel->setHeaderData (11, Qt::Horizontal, QObject::tr ("Notes"));
                  
                    ui->tableView_Fix->setColumnWidth (0, 60);
                    ui->tableView_Fix->setColumnWidth (1, 120);
                    ui->tableView_Fix->setColumnWidth (2, 150);
                    ui->tableView_Fix->setColumnWidth (3, 100);
                    ui->tableView_Fix->setColumnWidth (4, 130);
                    ui->tableView_Fix->setColumnWidth (5, 120);
                    ui->tableView_Fix->setColumnWidth (6, 400);
                    ui->tableView_Fix->setColumnWidth (7, 150);
                    ui->tableView_Fix->setColumnWidth (8, 200);
                    ui->tableView_Fix->setColumnWidth (9, 400);
                    ui->tableView_Fix->setColumnWidth (10, 130);
                    ui->tableView_Fix->setColumnWidth (11, 300);
                  
                    ui->tableView_Fix->setWordWrap (true);
                  
                  
                  }
                  
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #21

                    Why not use a QSqlTableModel ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    G 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Why not use a QSqlTableModel ?

                      G Offline
                      G Offline
                      gabor53
                      wrote on last edited by
                      #22

                      @SGaist
                      I had difficulties with the elegates. Can I still use different delegates for some columns? If so I will redo that section.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #23

                        Yes, you can.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        G 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          Yes, you can.

                          G Offline
                          G Offline
                          gabor53
                          wrote on last edited by
                          #24

                          @SGaist
                          Thank you.
                          I'm working on it.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved