Results 1 to 2 of 2

Thread: Problems with connect in conjunction with QT Designer

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with connect in conjunction with QT Designer

    Hi all,
    it seems to be simple but it isn't.

    Using the Designer I got the usual MainWindow class with
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. QObject::connect(ui->pushButton,SIGNAL(clicked()), this,SLOT(browse()));
    7. }
    8.  
    9. void MainWindow::browse()
    10. {
    11. QString directory = QFileDialog::getExistingDirectory(this,
    12. tr("Find Files"), QDir::currentPath());
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    As one can see I try to connect the clicked signal of a QPushButton to a slot of MainWindow ( which is by the way not visible in the Desinger)


    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4. public slots:
    5. void browse();
    6. public:
    7. explicit MainWindow(QWidget *parent = 0);
    8. ~MainWindow();
    9.  
    10. private:
    11. Ui::MainWindow *ui;
    12. QComboBox *fileComboBox;
    13. QComboBox *directoryComboBox;
    14. };
    To copy to clipboard, switch view to plain text mode 

    The code complies without an error and the application starts but the browse Method is never called if the button is clicked.

    What is going wrong here.

    Have fun
    dexli


    Added after 5 minutes:


    Don' know what happen but after recompiled it the x time it works.
    How do i delete this thread ??
    Last edited by dexli; 1st May 2011 at 19:08.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with connect in conjunction with QT Designer

    Probably the moc needed to be re-generated

Similar Threads

  1. Problems with Threads connect
    By Max123 in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2010, 12:20
  2. Designer hangs, trying to connect, while starting
    By darkadept in forum Qt Tools
    Replies: 1
    Last Post: 24th March 2009, 20:58
  3. qRegisterMetaType - problems with connect()
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2009, 22:55
  4. Designer doesn't connect the widgets
    By martinb0820 in forum Qt Tools
    Replies: 6
    Last Post: 6th November 2008, 14:18
  5. Qt Designer & Qt4, connect to my own slot.
    By geitosten in forum Newbie
    Replies: 2
    Last Post: 17th February 2007, 19:22

Tags for this Thread

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.