QGraphicsScene size
来源:百度文库 编辑:神马文学网 时间:2024/04/28 18:05:50
QGraphicsScene size
Hi
I am trying to create a GraphicsView where I can draw using the entire window. To do this I create a GraphicsScene with the view's rect as constructor. The result is that I get scrollbars (although it shouldnt be needed as the scene should be the same size as the view) that are pre-scrolled (why does it scroll by itself?) a few pixels in both directions. What am I doing wrong here?
Qt Code:Switch view#includeTo copy to clipboard, switch view to plain text mode#include #include #include int main(int argc, char* argv[]){QApplication app(argc, argv);QGraphicsView *view = new QGraphicsView;view->resize(640, 480);QGraphicsScene *scene = new QGraphicsScene(view->rect());scene->addItem(new QGraphicsSvgItem("ball.svg"));view->setScene(scene);view->show();return app.exec();}
Re: QGraphicsScene size
QRect is a little weird.
The size is actually with 1 pxiel smaller in each direction( 639x479).
So you have to adjust it a bit.
Also, I used setFixedxSize since if you resize it, the scroll bars appear again.
Qt Code:Switch viewint main(int argc, char* argv[]){QApplication app(argc, argv);QGraphicsView *view = new QGraphicsView;view->setFixedSize(640, 480);QRect r = view->rect();r.adjust(1,1,-1,-1);QGraphicsScene *scene = new QGraphicsScene(r);//scene->addItem(new QGraphicsSvgItem("ball.svg"));view->setScene(scene);view->show();return app.exec();}To copy to clipboard, switch view to plain text mode
Regards
QGraphicsScene size
Size Guide
what size..
Indexable Web Size
CSS Font-size Property
Tire Size Help
(SIZE-2)*(SIZE-2)棋盘骑士游历问题
C#中类的size
CSS:font-size-网页设计
Size Matters!全球最大数一数
Re: Finding size of a raw device
AGP Aperture Size(MB)具体含义
减肥,我要减SIZE保CUP
What is One Size Fits All?
减肥,我要减SIZE保CUP
女人 别减了Size却丢了Cup
急,一个关于open一个相当大的size的文件问题
a comparison of the size of the yahoo and google indices
“最佳性幻想车模”莉亚迪桑(21张图...
How to determine the size of a raw device (in a C programm)
谈谈font-size的控制及px与em的关系和特点
台湾现1200斤大“神猪”罕见(5张...
ListCtrl CTreeCtrl 操作 - 常见操作实例代码 - 石柱森林
武汉上空惊现毛泽东头像和中国地图(4...