Hello,
I want to extend a "stock" Qt widget with a custom widget.
For example I want to add a additional button to a spinbox.
To archive this i used the public accessible setLayout() function. The result is not what i epected. I want to add the button left or right of the standard QSpinBox.
See this small snippet.
#include <QApplication>
#include <QHBoxLayout>
#include <QPushButton>
#include <QSpinBox>
int main(int argc, char *argv[])
{
s.setLayout(hbl);
s.show();
return a.exec();
}
#include <QApplication>
#include <QHBoxLayout>
#include <QPushButton>
#include <QSpinBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSpinBox s;
QHBoxLayout * hbl = new QHBoxLayout();
hbl->addWidget( new QPushButton("Hello"));
s.setLayout(hbl);
s.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
qt.jpg
In my real code I have extended the "stock" Qt widget and therefore can also access the protected members.
Hoiw can i access the "real" layout of QSpinBox.
Is there another solution to archive my goal?
Greetings Gerd
Bookmarks