Results 1 to 8 of 8

Thread: QPushButton function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default QPushButton function

    Hey!

    I'm trying to insert a load of qpushbuttons with their own two images on the grounds that they are checkeable buttons but with a function. I want to do like this to simplify the code.

    My question is: How can I crontol where i put the buttons if i don't use a combox?
    I don't want to use combox because of the fact that i want to have the button and the images with the measure that i need.

    thanks!

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: QPushButton function

    sorry, I don't understand the questio. can you rephrase it, please?

    (What has all this to do with a combobox?)

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

    Default Re: QPushButton function

    Sorry, I was wrong!

    I didn't want to say combox. I don't want to do with a QGridLayout, because I need to insert a load of checkeable buttons ,that are going to chance the imange if they are clicked or not, with the measure that i want.
    The image is going to have the measure of the button to simulate as if they were checkeable images.

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: QPushButton function

    why is this a reason not to use a QGridLayout?

    you can also
    * subclass QWidget, put your button and a QLabel with the second image in it
    * subclass QPushButton and draw a second image on it

    Maybe draw a picture that shows what you want to achieve?

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

    Default Re: QPushButton function

    ok this is a graphic example.

    I
    Attached Files Attached Files

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: QPushButton function

    i would probably do something like

    Qt Code:
    1. class ButtonWithIcon : public QWidget
    2. {
    3. QAbstractButton *button_;
    4. QLabel *state_;
    5.  
    6. public:
    7. ButtonWithIcon(QWidget *parent=0) : QWidget(parent)
    8. {
    9. button_ = new QToolButton(...);
    10. l->addWidget(button_);
    11. state_ = new QLabel(...);
    12. l->addWidget(state_);
    13. setLayout(l);
    14.  
    15. button_->setCheckable(true);
    16. connect(button_, SIGNAL(toggled(bool)), SLOT(onToggle(bool)));
    17. }
    18.  
    19. private Q_SLOTS:
    20. void onToggle(bool on)
    21. {
    22. state_->setPixmap(... depending on on ...);
    23. }
    24.  
    25. };
    To copy to clipboard, switch view to plain text mode 

    A drawback is that the class itself is not a subclass of QAbstractButton.

    HTH

  7. #7
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPushButton function

    ok! i will try it!
    i will comment later.
    thanks!

  8. #8
    Join Date
    Dec 2006
    Location
    San Antonio, TX
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 2 Times in 2 Posts

    Default Re: QPushButton function

    Here is an example using properties and checking the state as well.

    Junior
    Attached Files Attached Files

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12: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
  •  
Qt is a trademark of The Qt Company.