Accessing qlabel created in designer from .h file.
-
hello.
I am new to qt.
I created a QLabel with object name imageLabel in qt desinger. The imageLabel created in this way is displayed in the main window.
How can we access this imageLabel in mainWindow.h?
Please let me know how I can access it.
And in vs++ it was possible to create a class object by making a static box into a picture box. Is it possible to create class object of imageLabel like this? -
ui->imageLabel
"And in vs++ it was possible to create a class object by making a static box into a picture box." - I don't understand this.
"Is it possible to create class object of imageLabel like this?" - imageLabel IS already an object.
-
@jsulm
Hi. thanks for your answer.
I mean...
In vc++, you can attach a static box when configuring a form design in a .rc file.
Set the id of this static as idc_picture. thenCPictureBox *m_picturebox=((CPictureBox *)m_nMainDlg->GetDlgItem(IDC_PICTUREBOX));
We can create a class like this.
class CPictureBox : public CStatic
-
@MyNameIsQt I still don't understand what you're trying to achieve. Can you describe it better?
-
This post is deleted!
-
@jsulm
I'm trying to load an image and draw it on a label. I want this label to be a class without being tied to a member variable.
In vc++, it was possible to include onPaint() event in picturebox(CStatic).
So I wanted to know how I could make something similar by making the object of qlabel a class. -
@MyNameIsQt said in Accessing qlabel created in designer from .h file.:
I want this label to be a class without being tied to a member variable
by making the object of qlabel a classSorry, I'm confused now. A class is NOT an object, an object is an instance of a class.
I think what you're actually asking is this: you want to subclass QLabel to create your own class based on QLabel, right?
But before we continue: do you really need to draw the picture manually? There are https://doc.qt.io/qt-6/qlabel.html#setPicture and https://doc.qt.io/qt-6/qlabel.html#pixmap-prop to set a picture on a label. -