tags:

views:

50

answers:

3

I am trying to make a chess game. So I am placing the board,coins as labels in a widget. Now I want to make the chess board as a non-movable label. Because if I clicks and moves the board, it's moving. How to constraint it.

A: 

I think you are using the wrong tool.

IMHO: You have to paint the board manually,or use graphics scene for this.

elcuco
+2  A: 

You might want to look into the Qt Graphics View Framework. A QGraphicsScene would be more appropriate for what you are trying to do.

Quote from the documentation:

The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.

The class serves as a container for QGraphicsItems. It is used together with QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is part of The Graphics View Framework.

codinguser
@mosfet it works. Thank you for your advice
prabhakaran
A: 

I also agree you should be using graphicsview or something else but to answer your question you could to this

label->setFixedSize(/*a qsize or to ints are passed see http://doc.qt.nokia.com/4.6/qwidget.html#setFixedSize*/);

I would do

label->setFixedSize (label->sizeHint()) this will make sure the size is fixed but it is the labels optimum size (all content is visible)
Olorin
@ Olorin I am trying to fix the label,thereby it won't move even if I drag it.
prabhakaran
after you applied the code I wrote it won't move ?
Olorin
@ Olorin Yes. Fixed size is to fix the size, not to constrain it's moving
prabhakaran