Button
-
in the UI from just drag and drop the button and also lineedit or textarea what ever u need to display the message . then note the object name of the pushbutton and the lineedit
thendecalre the function in the header file void on_but_clicked()
in the mainwindow.cpp add the Functio
@
void Mainwidget::on_but_clicked()
{
ui->line->settext("message");
}
@assume:
objectnameof the button = but
lineeditobject = line[EDIT: code formatting, please wrap in @-tags, Volker]
-
Depends.
If you've already got a main window with a button, you could use this:@
CMainWindow::CMainWindow()
{
...connect(m_ui->pButton, SIGNAL(pressed()), this, SLOT(SlotShowMessage()));
}void CMainWindow::SlotShowMessage()
{
QMessageBox::warning(this, tr("title"), tr("text"));
}
@If you're starting from scratch, you could use one of the tutorial projects (there should be at least one that demonstrates how to create a mainwindow) and base your application on it, then use code similar to what I've posted above.
-
-
Hi and welcome to devnet,
Please don't revive old thread. Did you follow Qt's documentation tutorials and examples ? They provide all the informations you need to get started