Results 1 to 3 of 3

Thread: connect problem

  1. #1

    Default connect problem

    Hi!
    Having a problem to connect a qlabel and qpushbutton.
    Here`s some code:
    Qt Code:
    1. QLineEdit *lineEdit = new QLineEdit;
    2. QLabel *copied = new QLabel;
    3. QPushButton *copy = new QPushButton("&Copy");
    4.  
    5. QDialog::connect(copy, SIGNAL(clicked()), copied, SLOT(setText(lineEdit->text())));
    6. QDialog::connect(copy, SIGNAL(clicked()), lineEdit, SLOT(clear()));
    To copy to clipboard, switch view to plain text mode 

    The first connect sentence isnt working. I`ve tried with setText("foobar"), but even then nothing happens with the label

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: connect problem

    you must write slot for this.
    corrent code
    Qt Code:
    1. ...
    2. connect(copy, SIGNAL(clicked()), this, SLOT(paste()));
    3. ...
    4.  
    5. void MyWidget::pate()
    6. {
    7. copied->setText(lineEdit->text());
    8. }
    To copy to clipboard, switch view to plain text mode 
    in connect you must describe signature of methods, but don't set real parameters. read this and you will find all answers Signals and Slots

  3. #3

    Default Re: connect problem

    Ah wonderful! This threw some light over the problem

    Thanks!

Similar Threads

  1. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  2. Problem with connect() (enum-type as parameter)
    By alu23 in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:46
  3. connect problem QDialog
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 1st January 2008, 13:36
  4. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.