向 Qt 工具栏区域添加图像
Adding an image to the Qt toolbar area
我正在制作一个 Qt 应用程序,在放置我的操作后,工具栏中仍然有很多空白 space。
我试图将图像添加到图标的右侧,并被告知可以使用 QLabel 对象并使用 QPixmap 放置图像。但是我无法将 QLabel 添加到工具栏。
QToolbar
already contains all the functionality you need. Simply user the addWidget(QWidget*
方法并向小部件(您的标签)提供 指针。
QLabel* label = new QLabel();
label->setPixmap(QPixmap("..."));
this->ui.toolbar->setWidget(label);
我正在制作一个 Qt 应用程序,在放置我的操作后,工具栏中仍然有很多空白 space。 我试图将图像添加到图标的右侧,并被告知可以使用 QLabel 对象并使用 QPixmap 放置图像。但是我无法将 QLabel 添加到工具栏。
QToolbar
already contains all the functionality you need. Simply user the addWidget(QWidget*
方法并向小部件(您的标签)提供 指针。
QLabel* label = new QLabel();
label->setPixmap(QPixmap("..."));
this->ui.toolbar->setWidget(label);