Results 1 to 8 of 8

Thread: How to save?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default How to save?

    Hi all

    I m working on Qt3.1 for Red Hat Linux, having a listview of items,
    Now what I want is when I pressed upon save button of the MainWindow than the items that are checked in the listview must be saved at the path that is selected by me using filedialog;

    Thanx
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to save?

    Quote Originally Posted by merry View Post
    Hi all

    I m working on Qt3.1 for Red Hat Linux, having a listview of items,
    Now what I want is when I pressed upon save button of the MainWindow than the items that are checked in the listview must be saved at the path that is selected by me using filedialog;

    Thanx
    Put the items in a QList, Whenever you check an item in listView, put that item in QList. In this way QList contains all the items which are checked. Now when you say 'save', open a filedialog to get the path where you want to dump the items.

    But by the way what do you have for listItems.????? Is it images???????

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to save?

    Thanx 4 ur reply

    Yes ListItems are directories and files which are represented by different images

    Thanx
    Always Believe in Urself
    Merry

  4. #4
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to save?

    Quote Originally Posted by merry View Post
    Thanx 4 ur reply

    Yes ListItems are directories and files which are represented by different images

    Thanx
    I dont know how you want the files and directories containing images to be saved but I have written a sample program which can help you to achieve your target.

    Here is the code

    Qt Code:
    1. bool myClass::outputSelectedListItems( QList* selectedListItems, QList* totalListItem )
    2. {
    3. if( ! selectedListItems->isEmpty() )
    4. {
    5. QListIterator it( totalListItem );
    6. QListItem* r;
    7. while( (r = it.current()) != 0 )
    8. {
    9. ++it;
    10. if( -1 != selectedRoutes->findRef( r ) )
    11. {
    12. //here you are sure what items are
    13. //selected so output accordingly
    14. }
    15. }
    16. return true;
    17. }
    18. else
    19. {
    20. return false;
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Hope this helps

  5. #5
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to save?

    Thanx for the reply


    I m sending U the code Which I had written :

    Qt Code:
    1. #include <qfiledialog.h>
    2. #include <qlistview.h>
    3. #include <qstring.h>
    4. #include <qfile.h>
    5. #include <qfileinfo.h>
    6. #include <qstringlist.h>
    7. #include<qmessagebox.h>
    8. #include <qpixmap.h>
    9. #include <qdir.h>
    10. #include <qstringlist.h>
    11.  
    12.  
    13. void Form1::init()
    14. {
    15. listView->setColumnWidth(1,0);
    16. listView->header()->setResizeEnabled(false,1);
    17. }
    18.  
    19. void Form1::fileOpen()
    20. {
    21. QListViewItem* root=new QListViewItem(listView);
    22. m_source = QFileDialog::getExistingDirectory(
    23. "/home/",
    24. this,
    25. "get existing directory",
    26. "Choose a directory",
    27. TRUE );
    28. root->setText(0,m_source);
    29. CreateDirTree(root,m_source);
    30. init();
    31. }
    32.  
    33. void Form1::CreateDirTree(QListViewItem *item,QString path)
    34. {
    35.  
    36. QDir dir(path);
    37. QDir dir1;
    38.  
    39. const QFileInfoList * dirs=dir.entryInfoList();
    40. {
    41. if(dirs)
    42.  
    43. {
    44. QFileInfoListIterator it(*dirs);
    45. QFileInfo * fileInfo;
    46. while(fileInfo=it.current())
    47. {
    48. ++it;
    49.  
    50. if(fileInfo->fileName() =="." || fileInfo->fileName() =="..")
    51. ;
    52. else if (fileInfo->isDir())
    53. {
    54. QString FilePath;
    55. FilePath =path +"/"+ fileInfo->fileName();
    56. m_temp = new QListViewItem(item);
    57. m_temp->setText(0,fileInfo->fileName());
    58. m_temp->setPixmap(0,QPixmap("/root/qt/Tree/images/folderunchecked.png"));
    59. CreateDirTree(m_temp,FilePath);
    60. }
    61.  
    62. else
    63. {
    64. m_temp = new QListViewItem(item);
    65. m_temp->setText(0,fileInfo->fileName());
    66. m_temp->setPixmap(0,QPixmap("/root/qt/Tree/images/fileunchecked.png"));
    67.  
    68. }
    69. }
    70. }
    71.  
    72.  
    73. connect ( listView ,SIGNAL(pressed(QListViewItem*)),this,SLOT(reverse_images(QListViewItem*)));
    74. }
    75.  
    76. }
    77. void Form1 :: reverse_images(QListViewItem* item)
    78. {
    79. const QPixmap *pixmap;
    80. pixmap=item->pixmap (0);
    81. QImage image;
    82. image=pixmap->convertToImage ();
    83. QImage *image1=new QImage("/root/qt/Tree/images/folderunchecked.png");
    84. QImage *image2=new QImage("/root/qt/Tree/images/folderchecked.png");
    85. QImage *image3=new QImage("/root/qt/Tree/images/fileunchecked.png");
    86. QImage *image4=new QImage("/root/qt/Tree/images/filechecked.png");
    87.  
    88. if(image1->operator==(image)==true)
    89. {
    90. item->setPixmap(0,QPixmap("/root/qt/Tree/images/folderchecked.png"));
    91. }
    92. else if(image2->operator==(image)==true)
    93. {
    94. item->setPixmap(0,QPixmap("/root/qt/Tree/images/folderunchecked.png"));
    95. }
    96. else if(image3->operator==(image)==true)
    97. {
    98. item->setPixmap(0,QPixmap("/root/qt/Tree/images/filechecked.png"));
    99. }
    100. else if(image4->operator==(image)==true)
    101. {
    102. item->setPixmap(0,QPixmap("/root/qt/Tree/images/fileunchecked.png"));
    103. }
    104.  
    105.  
    106. }
    To copy to clipboard, switch view to plain text mode 


    This is the code with which I got the listview of the items(files and folders) and also can checked ,unchecked the items. Now what I want is that when I click on the save button of the filemenu ->then all the checked items mustbe saved .


    thanx
    Last edited by wysota; 13th March 2007 at 07:55. Reason: changed [quote] to [code]
    Always Believe in Urself
    Merry

  6. #6
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to save?

    Quote Originally Posted by merry View Post
    Thanx for the reply


    I m sending U the code Which I had written :




    This is the code with which I got the listview of the items(files and folders) and also can checked ,unchecked the items. Now what I want is that when I click on the save button of the filemenu ->then all the checked items mustbe saved .


    thanx
    Take a QList<QListItem*> totalListItem and QList<QListItem*>selectedListItem. I assume that you know what is the total listItem displayed, put these items into totalListItem.
    I'm too assuming that when you check any listItem this fuction gets called

    Qt Code:
    1. reverse _images(QListViewItem*)
    To copy to clipboard, switch view to plain text mode 

    If that is the case then whenever you call reverse _images(QListViewItem*) function insert the selected item into selectedListItem. Then finally write a function called file save to save the images. Use the above defined function to save the images (defined in above post)

    Hope this helps

  7. #7
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to save?

    Hi

    Thanx for the help But I m working on Qt3.1 , in this ther is no function "QList"
    Can we save this by using the concept of linked list , If yes then pls tell me how bcoz i never used linked list before.


    Thanx
    Always Believe in Urself
    Merry

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to save?

    Use QPtrList or QValueList instead.

Similar Threads

  1. read files and save the,
    By kernel_panic in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2007, 06:31
  2. Save images to database
    By jnk5y in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2006, 19:56
  3. save animate to gif
    By Dmitry in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2006, 16:35
  4. Where does VS save its inviornment vars?
    By high_flyer in forum Installation and Deployment
    Replies: 5
    Last Post: 4th February 2006, 10:10
  5. What does "Save All" actually save?
    By Mariane in forum Newbie
    Replies: 7
    Last Post: 31st January 2006, 13:23

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.