Results 1 to 12 of 12

Thread: problems

  1. #1
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default problems

    I´m doing 2 buttons one disabled the other one. To do that I have done the following that:

    button.h

    Qt Code:
    1. #ifndef BUTTONS_H
    2. #define BUTTONS_H
    3.  
    4. #include <QWidget>
    5. #include <QBuffer>
    6.  
    7.  
    8. class QPushButton;
    9.  
    10. class buttons: public QWidget
    11. {
    12. Q_OBJECT
    13. public:
    14. buttons(QWidget *parent = 0);
    15.  
    16. private slots:
    17. void blocked();
    18.  
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 
    buttons.cpp

    Qt Code:
    1. QPushButton *deshabilitar = new QPushButton(tr("deshabilitar"), this);
    2. connect(deshabilitar, SIGNAL(clicked()),this, SLOT(blocked()));
    3.  
    4. QPushButton *Button7= new QPushButton(tr("Button7"), this);
    5.  
    6. void buttons:: blocked( )
    7. {
    8. Button7.setDisabled(true);
    9. }
    To copy to clipboard, switch view to plain text mode 



    Why am I having problems?
    Last edited by jpn; 16th July 2009 at 19:35. Reason: missing [code] tags

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    make Button7 a member of buttons class.

  3. #3
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems

    how??? I have done like this but it doesn´t work.


    Qt Code:
    1. #include <QtGui>
    2. #include <QPushButton>
    3. #include <QPixmap>
    4. #include <QIcon>
    5.  
    6. #include "buttons.h"
    7.  
    8. buttons::buttons(QWidget *parent)
    9. : QWidget(parent)
    10. {
    11.  
    12.  
    13. QPushButton *deshabilitar = new QPushButton(tr("deshabilitar"), this);
    14. connect(deshabilitar, SIGNAL(clicked()),this, SLOT(blocked()));
    15.  
    16. QPushButton *Button7= new QPushButton(tr("Button7"), this);
    17.  
    18. void buttons:: blocked( )
    19. {
    20. Button7.setDisabled(true);
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 16th July 2009 at 19:36. Reason: missing [code] tags

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    Qt Code:
    1. class buttons: public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. buttons(QWidget *parent = 0);
    6.  
    7. private slots:
    8. void blocked();
    9.  
    10. //LOOK HERE
    11. QPushButton *Button7;
    12.  
    13.  
    14. };
    15.  
    16. #endif
    17.  
    18. buttons.cpp
    19.  
    20. QPushButton *deshabilitar = new QPushButton(tr("deshabilitar"), this);
    21. connect(deshabilitar, SIGNAL(clicked()),this, SLOT(blocked()));
    22.  
    23. //LOOK HERE
    24. //QPushButton *Button7= new QPushButton(tr("Button7"), this);
    25. Button7= new QPushButton(tr("Button7"), this);
    26.  
    27. void buttons:: blocked( )
    28. {
    29. //FINALLY LOOK HERE
    30. //Button7.setDisabled(true);
    31. Button7->setDisabled(true);
    32. }
    To copy to clipboard, switch view to plain text mode 

    make other buttons the member as well

  5. #5
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems

    it doesn't work

    I take these errors:


    a function-definition is not allowed here before '{' token botoiak.cpp btns 140 C/C++ Problem
    make: *** [debug] Error 2 btns 0 C/C++ Problem
    make[1]: *** [tmp/obj/debug_shared/botoiak.o] Error 1 btns 0 C/C++ Problem

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    change this section to

    Qt Code:
    1. private slots:
    2. void blocked();
    3.  
    4. private://PUT THIS LINE
    5. //LOOK HERE
    6. QPushButton *Button7;
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    hey.. are you doing all the code in the buttons contstructor?

  8. #8
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems

    sorry but I don't get it:

    botoiak.h

    Qt Code:
    1. #ifndef BOTOIAK_H
    2. #define BOTOIAK_H
    3.  
    4. #include <QtGui/QWidget>
    5.  
    6. class botoiak : public QWidget
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. botoiak(QWidget *parent = 0);
    12.  
    13. private slots:
    14. void blocked();
    15.  
    16. private:
    17. QPushButton *Button7;
    18.  
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 

    botoiak.cpp

    Qt Code:
    1. #include <QtGui>
    2. #include <QPushButton>
    3. #include <QPixmap>
    4. #include <QIcon>
    5. #include <QApplication>
    6. #include "botoiak.h"
    7.  
    8. botoiak::botoiak(QWidget *parent)
    9. : QWidget(parent)
    10. {
    11.  
    12. QPushButton *habilitar = new QPushButton(tr("habilitar"), this);
    13.  
    14. QPushButton *deshabilitar = new QPushButton(tr("deshabilitar"), this);
    15. connect(deshabilitar, SIGNAL(clicked()),this, SLOT(blocked()));
    16.  
    17.  
    18. Button7= new QPushButton(tr("Button7"), this);
    19.  
    20. void botoiak:: blocked( )
    21. {
    22. Button7->setDisabled(true);
    23. }
    24.  
    25.  
    26. // setWindowTitle(tr("Botoiak"));
    27. //resize(400,400);
    28. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 16th July 2009 at 19:36. Reason: missing [code] tags

  9. #9
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    holy cow!!! you are inserting a slot defination inside the constructor...

    Qt Code:
    1. botoiak.cpp
    2.  
    3. #include <QtGui>
    4. #include <QPushButton>
    5. #include <QPixmap>
    6. #include <QIcon>
    7. #include <QApplication>
    8. #include "botoiak.h"
    9.  
    10. botoiak::botoiak(QWidget *parent)
    11. : QWidget(parent)
    12. {
    13.  
    14. QPushButton *habilitar = new QPushButton(tr("habilitar"), this);
    15.  
    16. QPushButton *deshabilitar = new QPushButton(tr("deshabilitar"), this);
    17. connect(deshabilitar, SIGNAL(clicked()),this, SLOT(blocked()));
    18.  
    19.  
    20. Button7= new QPushButton(tr("Button7"), this);
    21.  
    22.  
    23.  
    24.  
    25. // setWindowTitle(tr("Botoiak"));
    26. //resize(400,400);
    27. }
    28.  
    29. //Move it here
    30. void botoiak:: blocked( )
    31. {
    32. Button7->setDisabled(true);
    33. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Wink Re: problems

    thank you!! that was my big problem. Now it works.

  11. #11
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problems

    thx to god... if you have asked one more question i would have died.

  12. #12
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problems

    if you could please use the [ CODE ] tags for further post, because then one could read your code better. Second you could simply use:
    Qt Code:
    1. connect(deshabilitar, SIGNAL(clicked(bool)), Button7, SLOT(setEnabled(bool)));
    To copy to clipboard, switch view to plain text mode 
    assuming you button is not checkable.

Similar Threads

  1. Mac OSX OpenGL problems
    By tksharpless in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2009, 17:27
  2. flicker and wierd resize problems ...
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2008, 18:00
  3. Replies: 2
    Last Post: 8th March 2007, 22:22
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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.