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. How to recent signal from proxyModel to model?
Forum Updated to NodeBB v4.3 + New Features

How to recent signal from proxyModel to model?

Scheduled Pinned Locked Moved Solved General and Desktop
qsortfilterproxqtableviewqabstracttablem
4 Posts 3 Posters 528 Views
  • 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.
  • Z Offline
    Z Offline
    zloi_templar
    wrote on last edited by
    #1

    Hello, i have next problem "QObject::connect(QItemSelectionModel, mainForm): invalid null parameter"

    I just tried to connect signal, want to make some manipulations with form on selection, my code:

    connect(tbSC->selectionModel(), &QItemSelectionModel::selectionChanged, this, &mainForm::enableButtons);
    
    void mainForm::enableButtons(const QItemSelection &selected, const QItemSelection &)
    {
        foreach(QModelIndex index, selected.indexes())
        {
            if(mdlSC->Columns[index.row()][0].toString()=="")
                continue;
            else
            {
                ui->btnMS->setEnabled(true);
                break;
            }
        }
    }
    

    slot is not called

    I have next structure:

        tbSC = new tableSM(this);
        proxySM = new ProxyModelSM(tbSC);
        mdlSC = new modelSM(proxySM);
    
    ...
    
       proxySM->setSourceModel(mdlSC);
       tbSC->setModel(proxySM);
    

    class tableSM : public QTableView
    class modelSM : public QAbstractTableModel
    class ProxyModelSM : public QSortFilterProxyModel

    I think i must make smth like mapToSource, but idk how it make with signals, please help

    jsulmJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #3

      Your connect(tbSC->selectionModel() should be after tbSC->setModel(proxySM);

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      Z 1 Reply Last reply
      2
      • Z zloi_templar

        Hello, i have next problem "QObject::connect(QItemSelectionModel, mainForm): invalid null parameter"

        I just tried to connect signal, want to make some manipulations with form on selection, my code:

        connect(tbSC->selectionModel(), &QItemSelectionModel::selectionChanged, this, &mainForm::enableButtons);
        
        void mainForm::enableButtons(const QItemSelection &selected, const QItemSelection &)
        {
            foreach(QModelIndex index, selected.indexes())
            {
                if(mdlSC->Columns[index.row()][0].toString()=="")
                    continue;
                else
                {
                    ui->btnMS->setEnabled(true);
                    break;
                }
            }
        }
        

        slot is not called

        I have next structure:

            tbSC = new tableSM(this);
            proxySM = new ProxyModelSM(tbSC);
            mdlSC = new modelSM(proxySM);
        
        ...
        
           proxySM->setSourceModel(mdlSC);
           tbSC->setModel(proxySM);
        

        class tableSM : public QTableView
        class modelSM : public QAbstractTableModel
        class ProxyModelSM : public QSortFilterProxyModel

        I think i must make smth like mapToSource, but idk how it make with signals, please help

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @zloi_templar said in How to recent signal from proxyModel to model?:

        connect(tbSC->selectionModel(), &QItemSelectionModel::selectionChanged, this, &mainForm::enableButtons);

        Sounds like tbSC->selectionModel() returns a null pointer

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #3

          Your connect(tbSC->selectionModel() should be after tbSC->setModel(proxySM);

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          Z 1 Reply Last reply
          2
          • VRoninV VRonin

            Your connect(tbSC->selectionModel() should be after tbSC->setModel(proxySM);

            Z Offline
            Z Offline
            zloi_templar
            wrote on last edited by
            #4

            @VRonin yea, ty, already fix 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