Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Passare una QLineEdit ad uno SLOT
Forum Updated to NodeBB v4.3 + New Features

Passare una QLineEdit ad uno SLOT

Scheduled Pinned Locked Moved Solved Italian
3 Posts 2 Posters 902 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.
  • F Offline
    F Offline
    fermatqt
    wrote on last edited by
    #1

    ciao!

    ho due bottoni, ed a seconda di quello premuto dovrei riempire una QLineEdit piuttosto che un'altra.
    avrei fatto questo SLOT:

    void DialogAdd::setDir(QLineEdit *txt) {
        dir = QFileDialog::getExistingDirectory(this, tr("Scegli directory"), QDir::homePath(), QFileDialog::ShowDirsOnly);
        txt->setText(dir);
    }
    

    poi però ho difficoltà nel connect:

    connect(ui->btnSource, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtSource));
    connect(ui->btnDestinazione, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtDestinazione));
    

    in pratica ottengo questo errore:

    error: cannot take the address of an rvalue of type 'void'
    error: lvalue required as unary ‘&’ operand
         connect(ui->btnSource, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtSource));
                                                                                             ^
    

    come dovrei fare??

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2
      connect(ui->btnSource, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtSource));
      connect(ui->btnDestinazione, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtDestinazione));
      

      "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

      F 1 Reply Last reply
      0
      • VRoninV VRonin
        connect(ui->btnSource, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtSource));
        connect(ui->btnDestinazione, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtDestinazione));
        
        F Offline
        F Offline
        fermatqt
        wrote on last edited by
        #3

        @VRonin said in Passare una QLineEdit ad uno SLOT:

        connect(ui->btnSource, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtSource));
        connect(ui->btnDestinazione, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtDestinazione));
        

        grazie mille!!

        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