Inheriting QLabel doesn't work with pixmap[SOLVED]
-
Hi there currently trying to create a class that just fills a whole Qlabel with a image, when i run the code directly against a QLabel the code works fine and displays the icon.
@ QWidget *Test = new QWidget(this);
QLabel *label = new QLabel(Test);
//QPixmap picture("/home/tre/lxc/trunk/gui/src/radaron.png");
label->setPixmap(QPixmap(QString::fromUtf8("/home/tre/lxc/trunk/gui/src/radaron.png")));
label->show();setCentralWidget(Test);@
However when i try to introduce this code into the mainline it never works and im literally feel like im banging my head against a wall.
@GUIIndicationPanel::GUIIndicationPanel(QWidget * aParent,
const common::SiteId& aSiteId,
const lxc::gui::Panel& aPanel,
const GUIConfiguration& aConfiguration) :
QLabel::QLabel(aParent),
GUIFormElement::GUIFormElement(aSiteId, aPanel)
{
LOG_DEBUG << "Entered";std::stringstream lStringStream; setFrameStyle(QFrame::StyledPanel);
// int Labels = static_cast<int>(Displayable::MAX_LABELS);
// const Label *test = aPanel.labels(Labels);
this->setPixmap(QPixmap(QString::fromUtf8("/home/tre/lxc/trunk/gui/src/radaron.png")));// Set up the icons this button can use and set the current icon. //setFrameStyle(QFrame::Panel | QFrame::Raised); this->setScaledContents(true); setPanelIcon(aConfiguration); // Ensure this panel starts with the correct states applied. applyIconState(getIconState()); applyControlState(getControlState());
lStringStream << getDisplayableID() << " (" << getIconID() << ")"
<< "(" << getIconState() << ")"
<< "(" << getControlState() << ")";
setText(lStringStream.str().c_str());@Above is the constructor for GUIIndicationPanel which just inherits from Qlabel and another class (where you can see i've also tried to apply the pixmap inside the constructor).
In my gui form class file I call this by typing
@ CommsLostIndPanel = new GUIIndicationPanel(this,Site,*CommsLostPanel,*LocalConfig);
CommsLostIndPanel->setPixmap(QPixmap(QString::fromUtf8("/home/tre/lxc/trunk/gui/src/radaron.png")));@But nothing works, i've been trying this all day and I seem to be slowly losing my mind, so was hoping someone else have seen this problem before.
-
Well it seems pixmap just won't work with set text (even though that was the whole reason i wanted to use pixmap). Is there any way this can be achieve or will i have to use another method (for example creating a Qlabel ontop of the Qlabel image file)? I was really hoping i could just use both if anyone knows if this can be done that would be great.
Thanks -
Hi,
Nope it's either not both with QLabel.