Results 1 to 7 of 7

Thread: QTreeWidget SIGNAL

Hybrid View

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

    Default Re: QTreeWidget SIGNAL

    Qt Code:
    1. connect(ui.tree, SIGNAL(itemClicked (tables,0)), this, SLOT(selectTable()))
    To copy to clipboard, switch view to plain text mode 

    You can't set values in connect statements. You should use types there.

    Try this:
    Qt Code:
    1. connect(ui.tree, SIGNAL(itemClicked (QTreeWidgetItem*,int)), this, SLOT(selectTable()))
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QTreeWidget SIGNAL

    hi wysota!
    It works like this:
    Qt Code:
    1. connect(ui.tree, SIGNAL(itemClicked (QTreeWidgetItem*,int)), this, SLOT(selectTable()))
    To copy to clipboard, switch view to plain text mode 

    But i would like to call "selectTable()" just if i click a item of tables (not root and tables it self, but all items of tables should be able to call my function "selectTable()":
    Qt Code:
    1. .
    2. .
    3. QTreeWidgetItem *root = new QTreeWidgetItem(ui.tree);
    4. root->setIcon(0, QIcon(QString::fromUtf8(":/images/images/database.jpg")));
    5. root->setText(0, "inventar");
    6. QTreeWidgetItem *tables = new QTreeWidgetItem(root);
    7. .
    8. .
    To copy to clipboard, switch view to plain text mode 
    Thats why i tryed:
    Qt Code:
    1. connect(ui.tree, SIGNAL(itemClicked (tables,0)), this, SLOT(selectTable()))
    To copy to clipboard, switch view to plain text mode 

    Is that complex to implement?
    Think DigitalGasoline

  3. #3
    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: QTreeWidget SIGNAL

    You can't use parameter values in SIGNAL macro.
    You need to implement a slot for checking which item was clicked and then call selectTable() if appropriate.

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

    Default Re: QTreeWidget SIGNAL

    Provide a custom slot which checks values of those parameters.

    Qt Code:
    1. void someclass::someslot(QTreeWidgetItem *item, int column){
    2. if(item && column==0) selectTable();
    3. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QTreeWidget SIGNAL

    Hi everybody
    Ok i will do that!
    Is there a possibility to get my selected Item text? I found none function at QTreeWidget and QTreeWidgetItem
    . I found just "text()".
    In QT 3 i could use xx->currentText().

    Its easy to get my selected text or its not possible?
    Think DigitalGasoline

  6. #6
    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: QTreeWidget SIGNAL

    Qt Code:
    1. ui.tree->currentItem()->text()
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTreeWidget clicked signal
    By ^NyAw^ in forum Qt Programming
    Replies: 41
    Last Post: 30th January 2010, 11:42
  2. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  3. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  4. QTreeWidget fails to emit itemClicked signal.
    By avh in forum Qt Programming
    Replies: 2
    Last Post: 6th June 2008, 18:49
  5. QTreeWidget double click signal
    By Pinco Pallino in forum Newbie
    Replies: 2
    Last Post: 18th November 2006, 16:37

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.