0

I want to put QLabel into QToolBar. I do that but the QLabel changes QToolBar size, and does not fill it, see the first image below. What I need is make QLabel fill the QToolBar and resize the image, to be the same size as QLabel and QToolBar.

http://s10.postimg.org/62xos6hi1/pic_In_Bar.jpg

screenshot of what I want to happening: http://s2.postimg.org/3xsvtc5bd/pic_In_Bar1.jpg

I'm working with Qt 5.1, MinGw 4.8, and image type is .gif.

László Papp
  • 51,870
  • 39
  • 111
  • 135
Amr Eisa
  • 33
  • 5
  • 1
    It is not very clear from your question what you need and what is your problem. Putting some code and/or screenshots will be very helpfull – dvvrd Oct 29 '13 at 21:56
  • I add image link in main post. – Amr Eisa Oct 30 '13 at 07:44
  • may be screenshot of what you want and what is happening, will help – Kunal Oct 30 '13 at 08:37
  • this screenshot for real time but I need to make QLabel take full size into QToolBar and the same with QImage and in re-size the image re-size automatic. – Amr Eisa Oct 31 '13 at 02:40
  • @AmrEisa I edited your question a bit, based on how I understood it. Please check and correct if I misunderstood something. – hyde Nov 01 '13 at 07:51
  • @hyde, thanks :), sorry for my bad English. and for all too. – Amr Eisa Nov 01 '13 at 08:56

1 Answers1

1

Are you sure you must to use QLabel? Perhaps you should set the background image using Qt style sheets.

Link to customizing QToolBar.

hyde
  • 60,639
  • 21
  • 115
  • 176
  • this work for static Image I have gif Movie image. What I need is what border-image: url(:ImageInfo.ico); done but StyleSheet not working with animation gif file. – Amr Eisa Nov 01 '13 at 08:45
  • m_SoftImageLab = new QLabel( this ); QSizePolicy sizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum ); sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setVerticalStretch( 0 ); sizePolicy.setHeightForWidth( m_SoftImageLab->sizePolicy().hasHeightForWidth() ); m_SoftImageLab->setSizePolicy( sizePolicy ); m_SoftImageLab->setFrameStyle( QFrame::Panel | QFrame::Sunken ); QMovie *movie = new QMovie( ":/new/Data/Image/EiSa.gif" ); m_SoftImageLab->setMovie( movie ); movie->start(); ui->m_ImageTbar->addWidget( m_SoftImageLab ); – Amr Eisa Nov 01 '13 at 08:54
  • It's not what I'm looking for but I think it will do the job. – Amr Eisa Nov 03 '13 at 02:01
  • If it is important, and you find no other way to do it, there's always the option of subclassing QToolBar and seeing if you can do some custom painting (not sure if it would work, but I'm thinking of overriding `paintEvent`, drawing your own background, then calling superclass paintEvent to draw the rest). Or just writing your own toolbar widget from scracth, either on top of `QWidget` or using QML. – hyde Nov 03 '13 at 06:57