Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inheriting QLabel doesn't work with pixmap[SOLVED]

Inheriting QLabel doesn't work with pixmap[SOLVED]

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ion_knight
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ion_knight
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Nope it's either not both with QLabel.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved