Results 1 to 3 of 3

Thread: Why doesn't this button become invisible?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    10
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Why doesn't this button become invisible?

    I want a button to become invisible when I click on it. I'm inheriting from QPushButton and then promoting. I know the button is being created properly because when I put the setVisible part into the constructor, it works. It just doesn't work when I click on the button when the program is running, despite my attempt to override the QPushButton functions of click() or clicked(). What am I doing wrong here? How can I get this to work?

    Qt Code:
    1. #ifndef SOUNDBUTTON_H
    2. #define SOUNDBUTTON_H
    3.  
    4. #include <QPushButton>
    5.  
    6. class SoundButton : public QPushButton
    7. {
    8. public:
    9. SoundButton(QWidget *parent = 0);
    10.  
    11. void click();
    12. void clicked();
    13. };
    14.  
    15. #endif // SOUNDBUTTON_H
    16.  
    17. // the cpp file
    18.  
    19. #include "soundbutton.h"
    20. #include <stdio.h>
    21.  
    22. SoundButton::SoundButton(QWidget *parent)
    23. : QPushButton(parent)
    24. {
    25. printf("test me"); //doesn't output but not related to the problem
    26. }
    27.  
    28. void SoundButton::click()
    29. {
    30. this->setVisible(false);
    31. }
    32.  
    33. void SoundButton::clicked()
    34. {
    35. this->setVisible(false);
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 23rd July 2010 at 23:22.

Similar Threads

  1. setchecked( true) of the radio button doesn't work
    By richardander in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2009, 17:54
  2. why doesn't the button work?
    By mattia in forum Newbie
    Replies: 18
    Last Post: 5th November 2007, 12:14
  3. Replies: 4
    Last Post: 23rd November 2006, 05:24
  4. Replies: 2
    Last Post: 1st August 2006, 10:23
  5. [qt3]invisible toolbar
    By lszk in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2006, 18:34

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
  •  
Qt is a trademark of The Qt Company.