Results 1 to 20 of 23

Thread: send signal from QCombobox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: send signal from QCombobox

    Hi Guys..
    like that it works, but just if i dobleclick my combobox
    Qt Code:
    1. #include "test.h"
    2.  
    3. #include <QMessageBox>
    4. #include <QSqlDatabase>
    5. #include <QSqlQuery>
    6. #include <QSqlError>
    7. #include <QTextEdit>
    8. #include <QStatusBar>
    9. #include <QAbstractItemView>
    10. #include <QEvent>
    11.  
    12.  
    13.  
    14.  
    15. MainWindow::MainWindow()
    16.  
    17. {
    18. ui.setupUi(this);
    19. ui.sprache_cb->installEventFilter(this);
    20.  
    21.  
    22. connect(ui.actionverbinden, SIGNAL(triggered()), this, SLOT(verbinden()));
    23.  
    24.  
    25. }
    26.  
    27. bool MainWindow::verbinden()
    28. {
    29. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    30. db.setHostName("pcpsr5");
    31. db.setDatabaseName("DRIVER={SQL Server};SERVER=pcpsr5;DATABASE=inventar;UID=sa;PWD=");
    32. db.setUserName("sa");
    33. db.setPassword("");
    34. if(!db.open())
    35. {
    36. QMessageBox::information(this,"",db.lastError().text());
    37. return false;
    38. }
    39. else
    40. return true;
    41. }
    42. void MainWindow::selectSprache()
    43. {
    44. ui.sprache_cb->clear();
    45. ui.sprache_cb->insertItem(0,"");
    46. QSqlQuery select (" select sprache from sprache_tbl");
    47. while(select.next())
    48. {
    49. QString sprachen = select.value(0).toString();
    50. ui.sprache_cb->insertItem(1, sprachen);
    51. }
    52.  
    53. }
    54.  
    55. bool MainWindow::eventFilter( QObject *o, QEvent *e )
    56. {
    57. if ( e->type() == QEvent::MouseButtonPress )
    58. {
    59. selectSprache();
    60. return TRUE;
    61. }
    62. else
    63. return FALSE;
    64.  
    65. }
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: send signal from QCombobox

    try release event use
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: send signal from QCombobox

    Hi!
    I get new values just if i click twice..and on release the small button right from the combobox stay active (like a toogle button) until a click again ;(
    Qt Code:
    1. QEvent::MouseButtonRelease
    To copy to clipboard, switch view to plain text mode 

    May be its not the right way to send a Signal from the ComboBox..
    Think DigitalGasoline

  4. #4
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: send signal from QCombobox

    Hi,
    "QEvent::FocusIn" looks to work but i have a symptom..if i ordered my query the results are interchanged
    combo: x,f,a
    Query Analyzer: a,f,x

    "select sprache from sprache_tbl order by sprache"
    Think DigitalGasoline

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

    Default Re: send signal from QCombobox

    Quote Originally Posted by raphaelf
    Hi,
    "QEvent::FocusIn" looks to work but i have a symptom..if i ordered my query the results are interchanged
    combo: x,f,a
    Query Analyzer: a,f,x

    "select sprache from sprache_tbl order by sprache"
    Use "order by sprache desc" in your sql statement or add items to the combo box in reverse order, see last() and previous().

  6. #6
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: send signal from QCombobox

    Hi jpn!
    Thank you very much for your spended time..I have downloaded the example an i will use "desc" for my Query..

    Thanks all for the best support!
    Think DigitalGasoline

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

    Default Re: send signal from QCombobox

    Quote Originally Posted by raphaelf
    Hi!
    I get new values just if i click twice..and on release the small button right from the combobox stay active (like a toogle button) until a click again ;(
    Supposedly you want to populate the combo box only once, so maybe you could remove the event filter right after receiving the first appropriate event.

    Anyhow, I have included an example of the solution I suggested earlier...
    Attached Files Attached Files

  8. The following user says thank you to jpn for this useful post:

    aekilic (2nd January 2009)

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. QComboBox activated signal: bad int value?
    By rfdutt in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2008, 23:29
  4. Can you send a signal to a thread?
    By Dumbledore in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 20:31
  5. Manually send signal to slot
    By donmorr in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2006, 15:03

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.