[Qt-interest] (no subject)
Gan Xiebin
gan.xiebin at gmail.com
Mon May 25 08:53:13 CEST 2009
Hi,all.
I got a problem when i use setLayout to complete my " find dialog".
code:
// AutoSearchDlg.h
class AutoSearchDlg : public QDialog
{
Q_OBJECT
public:
AutoSearchDlg(QWidget *parent = 0);
public slots:
void SetupDialog();
private:
QLabel *textLabel;
QLabel *ipLabel;
QLineEdit *ipLineEdit;
QDialogButtonBox *buttonBox;
QPushButton *findButton;
QGridLayout *buttomLayout;
QVBoxLayout *mainLayout;
};
// AutoSearchDlg.cpp
AutoSearchDlg::AutoSearchDlg(QWidget *parent)
: QDialog(parent)
{
}
void AutoSearchDlg::SetupDialog()
{
textLabel = new QLabel(tr("Please input IP address and mask for
network search.\n"));
ipLabel = new QLabel(tr("IP Address:"));
ipLineEdit = new QLineEdit;
ipLabel->setBuddy(ipLineEdit);
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
buttomLayout = new QGridLayout;
buttomLayout->addWidget(ipLabel, 0, 0);
buttomLayout->addWidget(ipLineEdit, 0, 1);
buttomLayout->addWidget(buttonBox,2,2);
mainLayout = new QVBoxLayout;
mainLayout->addWidget(textLabel);
mainLayout->addLayout(buttomLayout);
setLayout(mainLayout);
exec();
}
// mainwindwo.cpp
#include "AutoSearchDlg.h"
MainWindow::MainWindow()
{
// create munu etc...
AutoSearchAct = new QAction(tr("Auto Search"), this);
connect(AutoSearchAct, SIGNAL(triggered()), new AutoSearchDlg(),
SLOT(SetupDialog()));
}
It's fined when i first triggered the "search" action on my main window,
but after that, when i triggered that action, the warning message
shows like that..
----------
QWidget::setLayout: Attempting to set QLayout "" on AutoSearchDlg "",
which already has a layout
------------
What can I do?
Thanks!
More information about the Qt-interest-old
mailing list