首页| 论坛| 消息

回复: 如何更改button的文字方向
#6 [hellogritty 03-08 20:47]
引用第4楼benbenmajia于2010-03-08 16:59发表的:
多加几个“n”?
hnen。。。。。。
我的button上显示的是英文,要每个字母都能转90度那样
#7 [benbenmajia 03-08 21:36]
做个位图吧
#8 [yb824 03-08 22:18]
试下~~~
.h
#include
class MyButton : public QPushButton
{
public:
MyButton(QWidget* parent=0);
protected:
void paintEvent(QPaintEvent *event);
};
.cpp
MyButton::MyButton(QWidget *parent)
:QPushButton(parent)
{
}
void MyButton::paintEvent(QPaintEvent *event)
{
QString txt = this->text();
setText("");
QPushButton::paintEvent(event);
setText(txt);
QPainter p(this);
p.rotate(90);
p.translate(0, -width());
QRect rect(this->rect().topLeft(),
QSize(this->rect().height(), this->rect().width()));
p.drawText(rect, Qt::AlignCenter, this->text() );
p.end();
}
#9 [hellogritty 03-09 09:35]
引用第8楼yb824于2010-03-08 22:18发表的:
试下~~~
.h
#include
class MyButton : public QPushButton
.......
感谢yb824提供的代码,文字转过来了,可是按钮还是原来的方向,没有随文字一起转,
要想按钮也转,该怎么做呢?
#10 [yb824 03-09 09:53]
把高度设大一点,宽度设小一点,感觉就是竖着的了

<< 1 2 3 >> (2/3)

回复 发表
主题 版块