[Qt-interest] Several problems (QState, QToolBar, QFileIconProvider, stylesheets...)
François KUBLER
francois at kubler.org
Fri Aug 6 10:40:13 CEST 2010
Hi guys,
I'm not really used to beggin' for help but I'm stuck with some problems
related to Qt. I spent hours and hours reading the docs and googling
without success. I also asked for help on IRC but, unfortunetly, noone
seemed to be able to help me (no offense). Seems like the mailing-list is
my last resort.
Just to makes things easier, I'm writing a small app with PyQt4 that looks
like this : http://francois.kubler.org/images/projets/z3nb0x_movies.png
Fact that I'm using PyQt4 shouldn't be a problem, any help will be
appreciated :)
1. Regarding QState + signal/slot :
As you can see on the screenshot, I have a QListView. This screen
corresponds to a QState that I called 'listState'. I have another state
which is called 'playerState' where the screen is a video player. The
problem I have is to switch from the 'listState' to the 'playerState' when
I click on a list item.
The important fact in this transition is that the playerState needs to
know what item has been clicked.
I played around with the QAbstractView::clicked ( const QModelIndex &
index ) signal and it works quite well.
My problem is that I can :
- add a transition to the 'playerState' using the QState::addTransition (
QObject * sender, const char * signal, QAbstractState * target ) method
with the clicked signal,
- OR retrieve the QModelIndex representing the clicked item using a basic
SIGNAL/SLOT connection.
But I need both !
I tried several things to do that without success (I can describe them if
you want, or even post code).
Is there a way to do that ? What am I missing ?
2. Regarding QToolBar/stylesheet :
2.a The first problem I have is that the icon size isn't respected. I
specify it in my stylesheet using :
QToolBar
{
icon-size: 48px;
}
The first time the bar appears, it's OK. But if I hide it and show it
back, the icon size gets back to what I believe is their default size.
I tried to show/hide the bar with the common show() and hide() method, and
also with the QMainWindow addToolbar() and removeToolbar() ones, without
success.
Setting the size with the QToolBar::setIconSize() method works, but I
would really need the stylesheet thing to work.
Is this a bug ? Am I doing something wrong ?
2.b Less important, I can't get rid of the QToolBar's rounded corner.
Again, I'm trying to do this via stylesheet, with the following statement :
QToolBar
{
border-radius: 0;
}
Weird thing is that if I put a value > 5px, it works ! Any idea ?
3. Regarding QFileIconProvider
As you can see on the linked screenshot, the list is a list of movies, and
I'd like to provide covers. I've written a small QFileIconProvider subclass
to do this. It simply gets the name of the file, and look if there is a
cover for it in a specified directory. Is this a good choice/the right way
to do that ?
In this class, I also specify that icons should be resized to a maximum of
32x32 pixmap. But, as you can see, it seems to be ignored. The items on the
list are much more bigger, and in fact, their size corresponds to what I
specify in my stylesheet (which is great). But I would have expected the
icons to be 32x32 and then resized to the bigger size set by the
stylesheet. The quality of the icons tends to prove I'm wrong. So, how does
the QFileIconProvider work ?
I know it's a long email so please accept my apologies if it's not the
place to ask that kind of questions.
Thanks a lot for your help, hints or ideas,
--
François
More information about the Qt-interest-old
mailing list