I'm trying to make a C++ Qt Widget Application using QtDesigner,
I have to override some menu items clicked events,
so how to override the QAction clicked event from .ui?
If I understand well you are looking for this:
Related
I am using Glade to create GUI. I have the default GtkColorChooserDialog.
How to set signals to the Select and Cancel button clicked event.
These two buttons are grouped in one GtkButtonBox and I can only choose the box, but not the buttons themselves.
If I can't select the button then how to assign action to the clicked signal?
I implement a UI with Qt. My UI is a mainwindow containing some widgets, and a supervisor to manage my widget behaviors. In one of my widget, outputDataWidget, I have a QTabWidget, and some other widgets.
In my tabWidget, I have a dataEditor to show points, and I create a "+" tab, to create a new tab. The tab creation is done by a connect function, which is in the mainwindow:
connect(outputWidget.get(), SIGNAL(SIG_createNewOutput(int)), projectSupervisor.get(), SLOT(sCreateNewOutput(int)));
My problem is: when we use the wheel mouse button in the tab header to go rigth, some new page are created. I would like intercept the signal and avoid the creation of a new tab.
I try to add a filter event in the mainwindow and in the outputdatawidget to ignore the wheel event. Then I try to reimplemeted wheelEvent(QWheelEvent* we) and event(QEvent *e) of the QTabWidget. Each time, we enter in thiese modification after call the connect (create the tab).
Have you an idea how to call the event before the connect, or how I can disable the wheelevent of a QTabWidget?
Thanks
You'll have to subclass QTabBar to handle the QWheelEvent, then call QTabWidget::setTabBar during initialization.
This is necessary because QTabWidget internally uses a QTabBar with Qt::WheelFocus, so the wheel event never propagates to the tab widget.
I'm implementing something similar to Eclipse's Package Explorer, using QTreeWidget, but I don't know how to handle right mouse button clicks.
How do I use Qt creator so I can handle right clicks on a QTreeWidgetItem?
You can set the context menu policy on the tree view item and then create a signal/slot event handlers as per usual.
For an example you can refer to this:
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(onCustomContextMenu(const QPoint &)));
Then just implement the onContextMenu function above
Is there a way to create a event to the QGraphicsView created without creating another class and inheriting the QGraphicsView?
I want to know if there's a way to do something like that:
ui->gView->AddEvent(click, functionName);
Thanks.
If you want to handle mouse click event for the view, install an event filter to the view and watch for MouseButtonPress event.
I have a QTableView in the main UI of my program. I'd like to show popup menu when user right clicks on the cells of the table and take appropriate action when an option is selected from the menu.
I am using Qt Creator 1 (Qt version 4.5). How can I do that?
Check out the customContextMenuRequested signal to get the event, and use a QMenu for the menu itself. Use QTableView::indexAt to find out what, if any, cell was clicked based on the coordinates given to the signal and take the appropriate action when a menu item is clicked.