Important: Please read the Qt Code of Conduct -

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");


    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) :
    GUIFormElement::GUIFormElement(aSiteId, aPanel)
    LOG_DEBUG << "Entered";

    std::stringstream lStringStream;

    // int Labels = static_cast<int>(Displayable::MAX_LABELS);
    // const Label *test = aPanel.labels(Labels);

    // Set up the icons this button can use and set the current icon.
    //setFrameStyle(QFrame::Panel | QFrame::Raised);
    // Ensure this panel starts with the correct states applied.

    lStringStream << getDisplayableID() << " (" << getIconID() << ")"
    << "(" << getIconState() << ")"
    << "(" << getControlState() << ")";

    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);

    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.

  • Lifetime Qt Champion


    Nope it's either not both with QLabel.

Log in to reply