[Qt-interest] how to judge which button click the QTreeWidgetItem?
prashant bhutani
prashantbhutani2008 at gmail.com
Thu Nov 4 10:38:59 CET 2010
Hi,
Even I tried searching for it but not able to find anything for
QTableWidget.
Only widgets, I found, who provide this facility rightButtonClicked() /
rightButtonPressed() are Q3IconView, Q3ListView, and Q3ListBox according the
documentation.
Please correct me, if I am wrong.
Prashant Bhutani
On Thu, Nov 4, 2010 at 2:38 PM, lvbing lvbing <lvbing1981 at gmail.com> wrote:
> hello all
> I have a QTreeWidget in my QMainWidows,and I have two functions,the one
> is left button click
> and the another is the right button to popup some Menu.
>
> The code like this:
>
> MainWindow::MainWindow() : QMainWindow()
> {
> setCentralWidget(view);
> view = new QTreeWidget(this);
> connect(view,SIGNAL(itemClicked ( QTreeWidgetItem *, int
> )),this,SLOT(on_MyTree_itemClicked( QTreeWidgetItem *, int )));
> init();
> }
>
> void MainWindow::on_MyTree_itemClicked ( QTreeWidgetItem * item, int column
> )
> {
> qDebug() << "on_MyTree_itemClicked"
> << item->text(column);
> //to do somthing
> }
>
>
> void MainWindow::contextMenuEvent(QContextMenuEvent * event)
> {
> qDebug() << "contextMenuEvent"
> << event->pos().x()
> << " and "
> << event->pos().y();
> //To popup the menu when I click the right mouse button!
> }
>
> But now I find when I clicked the right button,it will call
> the on_MyTree_itemClicked slot first!!
> and how can I distinguish the left or right button?
>
> thanks all
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101104/595f8166/attachment.html
More information about the Qt-interest-old
mailing list