how to connect QActions to SLOTS using qt designer - qt

I have created a nice looking toolbar using qt Designer and populated it with some actions.
I tried to connect the actions to slots visually from qt designer by clicking edit> signals and slots. This DID NOT WORK because i could not find any QAction signals.
Question.
Is there a way to connect the QAction SIGNAL(triggered()) to my slots within QT designer?
Please help.
PS:
I am currently being forced to connect through code:
QObject::connect(myAction, SIGNAL(triggered()),this, SLOT(myActionWasTriggered()))
but ia am lazy and i wish to connect using qt designer.

There's "Signal/Slot Editor" docked panel (Toggled with View->Signal/Slot Editor).
You can connect your actions there.
You may also need to add your custom slots via the "Change signals/slots" form context menu.
To save yourself some work, use the auto-connection feature (see QMetaObject::connectSlotsByName). Basically, all slots named with a specific pattern of on_objectName_signalName will be auto-connected.

Look here in Docs Designer Connection Mode... How to autconnect in the designer

Use the "Action editor" panel. You can find it near "Signals & Slots editor".

If you have menu, Please name your actions object according to menus , Suppose you have:
File Edit View Tools Help
You have 5 menus bar,
So you'll have a set of action_x , x is a number.Please naming your x according to your menu.
more explaintion:
File = 1
Edit = 2
View = 3
Tools = 4
Help = 5
And suppose :
File---> Open ..Close
Edit---> find...replace
View---> ZoomIn ... ZoomOut
Tools--->calender... prefrences
help---> help... about
You have 5x2 = 10 , you have 10 action, please manage such as:
action_11 == File>Open
action_12 == File>close
action_21 == Edit>find
and so on..
Above type of managing make easy your coding .....

Related

How to confirm the Widget Order in Qt Creator?

I've just defined the order in which I want my widgets on a Qt GUI but I can't confirm my action after hours of researches. How can I do it please ?
Here is the order I defined :
I would like the widgets to be in this order : 1 - 2 - 3
But here, there are in that order : 3 - 2 - 1
I tried to build the project to see if something different happens but it just builds exactly what I see on Qt Creator :
I read the tutorial below but there's no information about my problem : https://doc.qt.io/archives/4.3/designer-tab-order.html#:~:text=Setting%20the%20Tab%20Order,position%20in%20the%20tab%20order.
Btw, I don't understand why it's that complicated to do such a simple thing. It's crazy that just pressing the Enter key doesn't do the trick.
I found what I needed. To re-order widgets, we just have to move them manually with the mouse.

How to show DotDot path in QTableView using QFileSystemModel?

I apologize in advance for my English. I have QTableView with QFileSystemModel as model in my simple two-panel file manager. It displays files and directories correctly, but I want it to display DotDot line to move to the parent of the current directory. Setting QFileSystemModel::filter(QDir::AllEntries | QDir::NoDot) doesn't help, DotDot still doesn't display in QTableView. All of the above is true for Qt 5.9.1 on Windows 7. But when I build app on Ubuntu, it displays DotDot correctly, and QFileSystemModel::filter() perfectly works depending on it's arguments. Am I able to make it work on Windows 7 or it's a bug?
Here's simplified sample of my code:
QTableView *tableView = new QTableView;
QFileSystemModel *fsModel = new QFileSystemModel;
fsModel->setRootPath(QDir::rootPath());
fsModel->setFilter(QDir::AllEntries | QDir::NoDot);
tableView->setModel(fsModel);
QObject::connect(tableView, &QTableView::doubleClicked, tableView, &QTableView::setRootIndex);
tableView->show();
Make own class inherited from QFileSystemModel. And redefine virtual methods rowCount() and data().
That not simple way, but allow good control about content that show with that model. Of course you can add Dot and DotDot ( and even DotDotDotDot : ) )directories.

Retrieve different text from combo box in Qt Designer (pyqt)

this could sound strange and it is more a curiosity then a question.
I have a simple combobox with 2 elements in Qt Designer.
The 2 combobox elements are vertical and horizontal but for the script I'm writing I need to get only v or h.
Usually I easily do it with a loop like:
name = self.combbox.currentText()
if name == 'vertical':
name = 'v'
else:
name = 'h'
and that's ok.
I was just thinking if there is a way in Qt Designer to assign a kind of tag to the elements so the user sees the complete text but with the code it can be retrieved the tag.
Thanks to all
I don't believe you can do this with Qt Designer alone (see How can I add item data to QComboBox from Qt Designer/.ui file).
With some extra Python, though, you can add use setItemData() to add whatever extra data you want (How can I get the selected VALUE out of a QCombobox?) and retrieve it with itemData() and currentIndex().

Delete row button in alv grid in sap

i am using function "REUSE_ALV_GRID_DISPLAY" in order to display a grid. My problem is that not all the buttons in alv toolbar are displayed. For example, i can not see the "delete row" button.
This is my call:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = fieldcatalog
TABLES
t_outtab = lt_files_records_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
Can you please help?
IF you need the full editor functionality (including cell editors), you will have to move away from the (obsolete and unsupported) function module to the class CL_GUI_ALV_GRID. See the documentation here.
If you only need a delete button, it might be easier to add a custom button. Check the program SALV_DEMO_TABLE_FUNCTIONS for an example (and start using the ALV OM instead of the old function modules - much easier to code with).

identify tabs in QT Qtabwidget

if anyone has a good example of how can I identify that the user have chosen a tab in a window using QT provide it to me. I searched on line and the provided code give me error .. so here what I am trying to do :
I have a main window which has 3 tabs I will mainly show the same video on all of them but in each will run different algorithm, so I don't want them to run all the time because it will consume lots of processing from my cpu, so I would like to only make it work when the user select or open the tab .. here what I tried :
QObject::connect(ui->tabWidget, SIGNAL(ui->tabWidget->currentChanged(int idx)), ui->label, SLOT(setNum(int idx)));
and it gives me this error
Object::connect: No such signal QTabWidget::ui->tabWidget->currentChanged(int idx)
When you write a connect statement, do not include variable names or parameter names in the SIGNAL or SLOT macros. i.e., you should write this:
QObject::connect(ui->tabWidget, SIGNAL(currentChanged(int)), ui->label, SLOT(setNum(int)));

Resources