LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2010, 09:36 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Thumbnail view


How to I make a list of thumbnails in Qt, kind of like the "Icon View" in many GUI file managers?
 
Old 08-06-2010, 10:06 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
How to I make a list of thumbnails in Qt, kind of like the "Icon View" in many GUI file managers?
How is it Qt-specific ?

Scan (opendir, readdir) image files in the directory, resize them internally and display the images by Qt means.
 
Old 08-06-2010, 10:16 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I was thinking a file view-like thing, where you are able to select the thumbnails.
 
Old 08-06-2010, 10:19 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
I was thinking a file view-like thing, where you are able to select the thumbnails.
Selecting is mouse click registering, i.e. you need to read about mouse events in Qt.

And in addition probably mouse movement registering - there should be events related to mouse entering an leaving widget area.
 
Old 08-06-2010, 11:54 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
So you mean like the icon/thumbnail view in a Qt file manager is *not* a Q(List|Column|Table|Tree)View?
 
Old 08-06-2010, 12:01 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
So you mean like the icon/thumbnail view in a Qt file manager is *not* a Q(List|Column|Table|Tree)View?
I do not know Qt, so I can't answer your question specifically.

But I think you should split your problem into three:
  1. establishment of files <-> small images relationship;
  2. graphical display of the above small images (e.g. buttons showing them);
  3. actions in response to clicking/selecting entities with the small images.
.

There is bunch of Qt-based file managers and image viewers - yes, you will have to go through code written by others.
 
Old 08-09-2010, 04:06 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I found that QList actually does this, it has an Icon Mode, but the problem is how do I attach a QFileSystemModel (which is a tree) to it to list a certain directory?
 
Old 08-10-2010, 01:03 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Instead, I decided to try a QListWidget (not a QListView) and populate it like this:

Code:
QDirIterator i("/home/michael/Pictures");
while (i.hasNext())
{
    i.next();
    ui->fileList->addItem(new QListWidgetItem(QIcon(i.filePath()), i.fileName()));
}
But is has some problems:
  • It takes a REALLY long time to show, and it loads the CPU quite heavily just scrolling throught it.
  • What if the file is not an image file?
  • The icons aren't in a neat grid, instead they are scattered in an ugly fashion.

Last edited by MTK358; 08-10-2010 at 01:06 PM.
 
Old 08-10-2010, 01:44 PM   #9
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
I would write my own model.

Last edited by dugan; 08-10-2010 at 01:50 PM.
 
Old 08-10-2010, 02:09 PM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
Instead, I decided to try a QListWidget (not a QListView) and populate it like this:

Code:
QDirIterator i("/home/michael/Pictures");
while (i.hasNext())
{
    i.next();
    ui->fileList->addItem(new QListWidgetItem(QIcon(i.filePath()), i.fileName()));
}
But is has some problems:
  • It takes a REALLY long time to show, and it loads the CPU quite heavily just scrolling throught it.
  • What if the file is not an image file?
  • The icons aren't in a neat grid, instead they are scattered in an ugly fashion.
How about putting away excuses and looking into source code of, say 'konqueror' ?
 
Old 08-10-2010, 02:27 PM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Sergei Steshenko View Post
How about putting away excuses and looking into source code of, say 'konqueror' ?
I'd like to, but I am basically worthless at reading code that someone else wrote. Especially the relationships between all to files, functions, objects, etc.
 
Old 08-10-2010, 02:30 PM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
I'd like to, but I am basically worthless at reading code that someone else wrote. Especially the relationships between all to files, functions, objects, etc.
So, work on yourself. And starting from 'main' build the hierarchy.

And there are tools (start from 'ctags', 'cscope' and similar) and IDEs which help to understand "relationships between all to files, functions, objects, etc".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change thumbnail view for a text and pdf files arunmagar Linux - General 0 02-24-2010 05:35 AM
Thumbnail taskbar Jmumba Linux - Software 1 08-18-2008 09:47 PM
thumbnail swift2008 Programming 1 07-18-2008 08:13 AM
no thumbnail preview... bonito SUSE / openSUSE 5 06-19-2007 10:29 AM
Thumbnail Creator lapthorn Linux - Software 2 06-11-2004 08:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration