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. Slot parameter for QMetaObject::invokeMethod
Forum Updated to NodeBB v4.3 + New Features

Slot parameter for QMetaObject::invokeMethod

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 642 Views 1 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.
  • C Offline
    C Offline
    column
    wrote on last edited by
    #1

    Playing with QMetaObject::invokeMethod method :

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::setText( int value)
    {
        QString s = QString::number(value);
        ui->textEdit->setText(s);
    }
    
    
    
    
    
    void MainWindow::on_pushButton_clicked()
    {
        QGenericArgument genericArg =  Q_ARG(int, 321);
        bool inv = QMetaObject::invokeMethod( this,"setText",Qt::BlockingQueuedConnection, genericArg);
        qDebug("inv = %d\n", inv);
    }
    

    QMetaObject::invokeMethod returns false.

    I'm not sure regarding slot "setText". I took it from function name and I suppose it might be related. Where I can find list of slots at all? Should I create special slot for "setText"?

    Maybe it is related to fact I run it from the same thread?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      A slot is a ordinary c++ member method.
      For it to be a slot it should be listed under slots:

      class MainWindow: public QMainWindow { 
        Q_OBJECT   
      public:
      private slots:
        void MachineStatusClicked();
      public slots:
        void ShowOrderList();  
      private:
      

      so make sure you method is marked as a slot.

      1 Reply Last reply
      3

      • Login

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