Results 1 to 10 of 10

Thread: button question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: button question

    is there any widget that will do this, off the shelf?
    Yes - QPushButton
    Connect the clicked() signal to a slot, in that slot emit a QContextMenuEvent.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: button question

    How about using QToolButton? It supports a menu with three different popup styles, out of the box.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3

    Default Re: button question

    also any guide on how to do this?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: button question

    I gave you the 'guide', what more do you need?
    1. create a slot
    2. connect the clicked() signal to that slot
    3. in the slot emit the event

  5. #5
    Join Date
    Feb 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3

    Default Re: button question

    Quote Originally Posted by high_flyer View Post
    I gave you the 'guide', what more do you need?
    1. create a slot
    2. connect the clicked() signal to that slot
    3. in the slot emit the event
    in the book c++ gui programming with qt4 i found another way{create an action, populate a menu, connect the menu with button}


    Qt Code:
    1. oneAction= new QAction("do something!!", this);
    2. connect(oneAction, SIGNAL(triggered()), this, SLOT(action()));
    3. processMenu->addAction(oneAction);
    4. menuButton->setMenu(&processMenu);
    To copy to clipboard, switch view to plain text mode 

    what is the difference? between these 2 ways?
    Last edited by aegis; 31st March 2007 at 19:29.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: button question

    That's exactly the same what Jpn suggested.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: button question

    what is the difference? between these 2 ways?
    The method from the book that Jpn suggested uses QActions and signals.
    I find it also better, so use it.
    The other method is using an event, which probably is what happens with the signal method behind the scenes.

  8. #8
    Join Date
    Feb 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3

    Default Re: button question

    Quote Originally Posted by high_flyer View Post
    Yes - QPushButton
    Connect the clicked() signal to a slot, in that slot emit a QContextMenuEvent.
    any guide on how to do this?

Similar Threads

  1. Disable Checkable Button Question
    By jbpvr in forum Qt Programming
    Replies: 9
    Last Post: 20th March 2007, 17:57
  2. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 05:03
  3. Button with signals and slots
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2006, 22:24
  4. Push button double click
    By curtisw in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2006, 16:40
  5. QLabel on a Button
    By cwalsh in forum Newbie
    Replies: 4
    Last Post: 12th January 2006, 16:06

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.