Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt::NoOpaqueDetection
Forum Updated to NodeBB v4.3 + New Features

Qt::NoOpaqueDetection

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 472 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nanamo
    wrote on last edited by
    #1

    Hi Guys
    Apologies I'm a noob,what I want to do is set the flag Qt::NoOpaqueDetection when creating my QPixmap.
    I've searched for ages with no luck.
    How exactly do I set this flag when creating my pixmap like below, is it possible?

    Myicon->setOnPixmap(QPixmap(myimage);
    

    Something like this but this doesnt work

    Myicon->setOnPixmap(QPixmap(myimage, Qt::NoOpaqueDetection);
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Qt::NoOpaqueDetection is a flag for a QImage conversion, not for something during drawing. What do you want to achieve and why do you think you need this flag?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      N 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Qt::NoOpaqueDetection is a flag for a QImage conversion, not for something during drawing. What do you want to achieve and why do you think you need this flag?

        N Offline
        N Offline
        nanamo
        wrote on last edited by
        #3

        @Christian-Ehrlicher Ah ok, thank you
        When I click on my QPixmap when it is within a QLabel the click only registers on the non-opaque sections of the PNG image.
        I want to register a click on the entire 200x200 PNG, as it can be difficult for the user to press the button when they must hit the non-transparent bits.
        So i thought that flag would turn off opaque detection. (I need to maintain transparency for appearances and I must maintain using QLabel)
        The search continues...

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you display a transparent QLabel? Please show some code.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          N 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Do you display a transparent QLabel? Please show some code.

            N Offline
            N Offline
            nanamo
            wrote on last edited by
            #5

            @Christian-Ehrlicher Yes The problem line is

            icon->setAttribute(Qt::WA_TranslucentBackground, true);
            

            If I remove that line i can click the entire PNG image of 200x200 pixels but I lose the transparency.
            Need to maintain transparency but also click area.

            mainArea::mainArea(QWidget *parent) :QLabel(parent)
            icon->setObjectName(name);
            icon->setGeometry(QRect(x, y, w, h));
            icon->setOnPixmap(QPixmap(imgOnInd_dm));
            icon->setOffPixmap(QPixmap(imgOffInd_dm));
            
            icon->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
            icon->setVisible(vis);
            QObject::connect(icon, SIGNAL(clicked()), this, SLOT(btnClicked()));
            
            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              This is not possible afaik since the window manager will not send events to this QLabel when the click is on an opaque pixel.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              N 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                This is not possible afaik since the window manager will not send events to this QLabel when the click is on an opaque pixel.

                N Offline
                N Offline
                nanamo
                wrote on last edited by
                #7

                @Christian-Ehrlicher Ok thanks for that, it'll save me looking any further

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved