1
我夥計們,
的Qt 5.1版本
我現有的QT項目工作,我不明白爲什麼當我點擊按鈕,就不能在插槽中啓動功能Qpush按鈕 - >點擊信號從QPushButton沒有火起來的功能插槽
我想要做的是我的Qt應用程序連接到網絡,並使用QTreewidget顯示所有機器與他們的MAC地址。這部分工作正常 我的巢任務是從上面的步驟中創建的QTree對象中選擇mac-adrress,然後創建一個按鈕以在該機器上啓動升級過程。
下面是我的源代碼
1)的main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Regular_Work w;
w.show();
return a.exec();
}
2)regular_work.cpp
Regular_Work::Regular_Work(QWidget *parent)
: QMainWindow(parent),macAdd_tree_p_(0), reg_upgrade_button_(0),
box_table_p_(0),
udp_listner_p_(0)
{
ui.setupUi(this);
// Create the main view
create_main_view(this, macAdd_tree_p_, box_table_p_ , reg_upgrade_button_);
init(); // this function upgradels other signals and slots from other class to find the network and upgradel the slots which displays teh tree view of mac address connected to a network.
create_menu_actions();
}
Regular_Work::~Regular_Work()
{
}
// this function is called from another slot when itemClicked signal is received from QTreeWidgetItem
void Regular_Work::set_reg_upgrade_button_visible(Regular_Work* main_p)
{
QPushButton* reg_upgrade_button = new QPushButton ("Regular_upgradei");
reg_upgrade_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding) ;
QWidget* centralWidget = new QWidget(main_p);
centralWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QHBoxLayout* layout = new QHBoxLayout(centralWidget);
layout->addWidget(reg_upgrade_button_);
main_p->setCentralWidget(centralWidget);
reg_upgrade_button->setVisible(true);
connect(reg_upgrade_button, SIGNAL(clicked()), main_p, SLOT(start_Work("start Work"))); // this is teh problem ?
}
void Regular_Calibration::start_Work(const QString& error_message)
{
QMessageBox::information(this,
tr("Push button works "),
error_message);
}
非常感謝您的幫助
@ Merlin09非常感謝Merlin,你的解釋非常好,以及你的代碼。 – samprat
不客氣; O) – TheDarkKnight