Results 1 to 20 of 32

Thread: Qcombobox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Qcombobox

    Hi

    I have QCombox without items. After clicking on the combobox I would like to showmessage but I cannot find slot "Clicked" or something similar.

    How to do it ?

    Regards
    Artur

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

    Default Re: Qcombobox

    There is no such signal. If you want to have one, subclass, reimplement mouse events and emit such signal yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2015
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qcombobox

    ... in short, add a pushButton, eish, that is just mean - lol.

  4. #4
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qcombobox

    No. Do as Wysota has said. The mouse event will hook clicking the combo box and emit a "clicked" signal - perhaps only sometimes (when the combo box is empty). If the combo box isn't empty, you get a signal from the clicked item.

  5. #5

    Default Re: Qcombobox

    If it is not problem please give me an example.

    Thank you for help

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

    Default Re: Qcombobox

    Quote Originally Posted by arturs View Post
    If it is not problem please give me an example.
    An example of what?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7

    Default Re: Qcombobox

    How to do it using QMouseEvent.
    How to determine that the left button of mouse was clicked on the Combobox.

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

    Default Re: Qcombobox

    Quote Originally Posted by arturs View Post
    How to do it using QMouseEvent.
    How to determine that the left button of mouse was clicked on the Combobox.
    Qt Code:
    1. void Combo::mousePressEvent(QMouseEvent *e) {
    2. if(e->button() == Qt::LeftMouseButton) emit clicked();
    3. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9

    Default Re: Qcombobox

    My Code
    Qt Code:
    1. void Test::mouseMoveEvent(QMouseEvent *event)
    2. {
    3. if (event->button()==Qt::LeftButton) emit clicked();
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    Should I create clicked signal ? because Now I have the following error: 'clicked' was not declared in this scope

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

    Default Re: Qcombobox

    Quote Originally Posted by arturs View Post
    Should I create clicked signal ?
    If you want to emit a signal, the signal has to exist. So yes, you need to declare the signal in your class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11

    Default Re: Qcombobox

    but It is still not clear for me. The signal will be sent each time when the left button of mouse is clicked even if the pointer of mouse there is out of Combobox area.

    Second question:
    Is it possible to check using a method if a slot was called by signal or was called another method

    for example:


    I have a slot

    Qt Code:
    1. void Test:: test1 (void) {
    2.  
    3. qDebug () << "TEST";
    4. }
    To copy to clipboard, switch view to plain text mode 

    I can call it using the following code:
    test();

    or it can be called by signal.

    I would like to know which method was used to call the slot.

Similar Threads

  1. Replies: 1
    Last Post: 20th May 2015, 11:21
  2. QComboBox
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2014, 14:14
  3. QComboBox
    By kavinsiva in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2009, 16:11
  4. QComboBox
    By bismitapadhy in forum Qt Programming
    Replies: 7
    Last Post: 15th July 2009, 06:01
  5. QComboBox
    By coderbob in forum Qt Programming
    Replies: 4
    Last Post: 12th December 2007, 06:38

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.