Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Doesn't know what to use



  • Hi, thanks for taking the time to instruct me.

    I would like to create a widget for my QTabWidget. I would like something like this

    0_1527446068971_WhatIWant.png

    I tried with QPushButton (QHBoxLayout, QVBoxLayout) ans QAction (QMenu, QMenuBar) but the I can't manage to create an harmony AND the last 2 button doenst appear (I made the image with paint)

    For QPushButton, here the result :

    :0_1527454053277_WhatIWant2.png

    For some reason the two bottom button sprite doesn't appear.

    QPixmap *pixUpMap = new QPixmap("upMap.png");
    upMap = new QPushButton;
    upMap->setIcon(*pixUpMap);
    upMap->setIconSize(pixUpMap->size());

    Did QPushButton only accept square image?

    Is there some class I don't know yet that could help me with that?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    First thing: there's no need in your case to allocate your QPixmap on the heap.

    Now your real problem is that you are using a relative path for your upMap.png file. Since by default Qt Creator uses shadow build (which is a good thing), the file won't be found at execution time. Either integrate your images using Qt's resource system or use the full path to them.



  • Thanks for the tips. It didn't work but I have found a way to make it work. The two image I was trying to use were created by a "right-clic, new, bitmap" and I changed their extention in ".png".
    So I re-create them and now, it works out well :

    0_1527458492974_final.png



  • @DPixel if your issue is solved, please don't forget to mark your post as such. Thanks


Log in to reply