Results 1 to 5 of 5

Thread: how can we move an image?

  1. #1
    Join Date
    Nov 2008
    Posts
    52
    Qt products
    Qt4
    Platforms
    Windows

    Default how can we move an image?

    how can we move an image up & down

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how can we move an image?

    what do you mean? using mouse? keyboard? or programmatically?
    provide more information, please.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Nov 2008
    Posts
    52
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can we move an image?

    programmatically.sorry for the incomplete information.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how can we move an image?

    You're still not being too clear. Remember that we don't know anything about the application you're writing. An image can be shown in many ways. It would be crucial information for us to know how you do it to be able to help you.
    J-P Nurmi

  5. #5
    Join Date
    Nov 2008
    Posts
    52
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can we move an image?

    The following is the code:
    Qt Code:
    1. Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) :
    2. Q3MainWindow(parent,name,f),
    3. canvas(c)
    4. {
    5. editor = new FigureEditor(canvas,this);
    6. QMenuBar* menu = menuBar();
    7. QPushButton *rotate1 = new QPushButton(tr("Rotate->"), this);
    8. rotate1->setGeometry(2, 0, 55, 20);
    9. connect(rotate1, SIGNAL(clicked()), this, SLOT(rotateClockwise()));
    10.  
    11. QPushButton *rotate2 = new QPushButton(tr("Rotate<-"), this);
    12. rotate2->setGeometry(2, 18, 55, 20);
    13. connect(rotate2, SIGNAL(clicked()), this, SLOT(rotateCounterClockwise()));
    14.  
    15. QPushButton *zoom_in = new QPushButton(tr("zoom_in"), this);
    16. zoom_in->setGeometry(2, 36, 55, 20);
    17. connect(zoom_in, SIGNAL(clicked()), this, SLOT(zoomIn()));
    18.  
    19. QPushButton *zoom_out = new QPushButton(tr("zoom_out"), this);
    20. zoom_out->setGeometry(2, 54, 55, 20);
    21. connect(zoom_out, SIGNAL(clicked()), this, SLOT(zoomOut()));
    22.  
    23. QPushButton *moveup = new QPushButton(tr("moveUp"), this);
    24. moveup->setGeometry(2, 72, 55, 20);
    25. connect(moveup, SIGNAL(clicked()), this, SLOT(moveU()));
    26.  
    27. QPushButton *movedown = new QPushButton(tr("movedown"), this);
    28. movedown->setGeometry(2, 90, 55, 20);
    29. connect(movedown, SIGNAL(clicked()), this, SLOT(moveD()));
    30.  
    31. QPushButton *moveleft = new QPushButton(tr("moveleft"), this);
    32. moveleft->setGeometry(2, 108, 55, 20);
    33. connect(moveleft, SIGNAL(clicked()), this, SLOT(moveL()));
    34.  
    35. QPushButton *moveright = new QPushButton(tr("moveright"), this);
    36. moveright->setGeometry(2, 126, 55, 20);
    37. connect(moveright, SIGNAL(clicked()), this, SLOT(moveR()));
    38.  
    39. xval=0;
    40. yval=0;
    41.  
    42. setCentralWidget(editor);
    43.  
    44. printer = 0;
    45.  
    46. init();
    47. }
    48. void Main::rotateClockwise()
    49. {
    50. editor->rotate( 5 );
    51. }
    52.  
    53. void Main::rotateCounterClockwise()
    54. {
    55. editor->rotate( -5 );
    56. }
    57.  
    58. void Main::zoomIn()
    59. {
    60.  
    61. editor->scale( 1.1, 1.1 );
    62. }
    63.  
    64. void Main::zoomOut()
    65. {
    66. editor->scale( 0.9, 0.9 );
    67. }
    68.  
    69. void Main::mirror()
    70. {
    71. editor->scale( -1, 1 );
    72. }
    73.  
    74. void Main::moveL()
    75. {
    76. editor->translate( -16, 0 );
    77. }
    78.  
    79. void Main::moveR()
    80. {
    81. editor->translate( +16, 0 );
    82. }
    83.  
    84. void Main::moveU()
    85. {
    86. yval++;
    87. editor->translate( 0, -660 );
    88. }
    89.  
    90. void Main::moveD()
    91. {
    92. xval++;
    93. editor->translate( 0, +660 );
    94. }
    To copy to clipboard, switch view to plain text mode 
    Here the image is getting rotated clockwise & anticlockwise but not moving up,down,left & right.sorry for not using code tags instead of 2 warnings.I followed the link given by you but i could'nt understand how to use code tags.
    Last edited by wysota; 24th January 2009 at 13:20. Reason: missing [code] tags

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  3. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.