ok, another little problem with dynamic QLabels and buttons:
void Explorer::setEquipment() {
QObject::connect(items,
SIGNAL(clicked
()),
mainLabel, SLOT(showFriends()));
items-> move(47,277);
items-> setStyleSheet("color: white; font-family:Verdana, Sans-serif; font-weight:bold; border: none;");
}
void Explorer::showFriends() {
msgBox.setText("Friends label");
msgBox.exec();
friendsLabel
= new QLabel("TEST");
}
void Explorer::setEquipment() {
QPushButton *items = new QPushButton("Friends", mainLabel);
QObject::connect(items, SIGNAL(clicked()),
mainLabel, SLOT(showFriends()));
items-> move(47,277);
items-> setStyleSheet("color: white; font-family:Verdana, Sans-serif; font-weight:bold; border: none;");
}
void Explorer::showFriends() {
QMessageBox msgBox;
msgBox.setText("Friends label");
msgBox.exec();
friendsLabel = new QLabel("TEST");
}
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
Explorer(char *name);
void mainWindow();
void open(char *fileName);
void setEquipment();
private slots:
void showFriends();
};
class Explorer : public QMainWindow
{
Q_OBJECT
public:
Explorer(char *name);
void mainWindow();
void open(char *fileName);
QLabel *mainLabel;
QLabel *friendsLabel;
void setEquipment();
private slots:
void showFriends();
};
To copy to clipboard, switch view to plain text mode
the new QLabel doesn't appear after clicking
BTW How to debug this kind of problems?
EDIT:
ok, all what was needed was:
friendsLabel->show();
friendsLabel->show();
To copy to clipboard, switch view to plain text mode
Bookmarks