[Solved] Connect combobox using signals
-
@p3c0
thank you.
I used this
combobox = new QComboBox(this);
Is it the proper way to do it ?@Ratzz Correct. Now the rest should work. Just don't forget to change the slot's definition.
-
@Ratzz Because in you have connected the signal
activated
to slotm_combobox
which takes one argument.
connect(combobox,SIGNAL (activated(int)),this,SLOT(m_combobox(int)));
But there is no such slot defined with single argument and thus the connection will fail as it will not be able to find that slot. You have a slotm_combobox()
which takes no arguments. -
@p3c0
i used setGeometry() to assign position-
pushbutton->setGeometry(QRect(QPoint(100, 200),QSize(90, 40)));
How to do use move();?
@Ratzz pushbutton->move(10,100). See http://doc.qt.io/qt-5/qwidget.html#pos-prop
But as said earlier its best to use Layouts. See using Layouts for more details. -
-
@Ratzz
connect(combobox,SIGNAL (activated(int)),this,SLOT(m_combobox(int)));
-> This is correct
mainwindow.hprivate slots: void m_combobox(int index);
mainwindow.cpp
void MainWindow::m_combobox(int index) { label->setText("1"); }
-
@Ratzz You're Welcome :)
Since you are new here few more forum related reminders:- Always surround the code blocks with ``` (3 backticks) while posting so that it gets nicely formatted and thus more readable for others.
- Mark the post as solved by editing the post title and prepending [Solved]
Happy Qt Coding ...
22/22