base->setGeometry(50,50,160,30);
base->setStyleSheet("background: #ffffff; border-radius: 5px;");
base->setCursor(Qt::PointingHandCursor);
button->setGeometry(0,0,160,30);
button->setCheckable(false);
button->setStyleSheet("background: transparent; border-radius: 5px; padding-left: 9px; text-align: left; ");
connect(button,SIGNAL(clicked()),this,SLOT(myslot()));
void MyClass::myslot()
{
QPushButton *button
= qobject_cast<QPushButton
* >
(pObject
);
QFrame *container
= qobject_cast<QFrame
* >
(button
->parentWidget
());
int x = container->rect().height();
qDebug() << "Height : " << x << endl; //prints correct value
qDebug() << "Text: " << button->text() << endl; // prints correctly as well
button->setVisible(false); //this works
newWidget->setGeometry(0,0,160,150);
newWidget->setStyleSheet("background: #ffffff; border-radius: 5px;");
newWidget->setCursor(Qt::PointingHandCursor); //doesn't work
container->stackUnder(newWidget);
}
QFrame *base = new QFrame(parent);
base->setGeometry(50,50,160,30);
base->setStyleSheet("background: #ffffff; border-radius: 5px;");
base->setCursor(Qt::PointingHandCursor);
QPushButton *button = new QPushButton("Some text",base);
button->setGeometry(0,0,160,30);
button->setCheckable(false);
button->setStyleSheet("background: transparent; border-radius: 5px; padding-left: 9px; text-align: left; ");
connect(button,SIGNAL(clicked()),this,SLOT(myslot()));
void MyClass::myslot()
{
QObject* pObject = sender();
QPushButton *button = qobject_cast<QPushButton* >(pObject);
QFrame *container = qobject_cast<QFrame* >(button->parentWidget());
int x = container->rect().height();
qDebug() << "Height : " << x << endl; //prints correct value
qDebug() << "Text: " << button->text() << endl; // prints correctly as well
button->setVisible(false); //this works
QFrame *newWidget = new QFrame(container);
newWidget->setGeometry(0,0,160,150);
newWidget->setStyleSheet("background: #ffffff; border-radius: 5px;");
newWidget->setCursor(Qt::PointingHandCursor); //doesn't work
container->stackUnder(newWidget);
}
To copy to clipboard, switch view to plain text mode
Bookmarks