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. How can we just display image if we don't have any base widget?
Forum Updated to NodeBB v4.3 + New Features

How can we just display image if we don't have any base widget?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.6k 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    When i will run program I want to just display image not any window how can i do it?

    Pratik Agrawal

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dmcr
      wrote on last edited by
      #2

      I think you can't.
      But you can display a frameless window
      with setWindowFlags(Qt::FramelessWindowHint) and you won't see any border.

      dmcr

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p-himik
        wrote on last edited by
        #3

        I think something like this:
        @#include <QApplication>
        #include <QLable>
        #include <QPixmap>

        int main( int argc, char* argv[] )
        {
        QApplication app( argc, argv );
        QLabel imageLabel;
        imageLabel.setPixmap( QPixmap( "/path/to/your/image" ) );
        imageLabel.show();
        return app.exec();
        }@

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          You cannot display anything without a window, but you can display a window without a frame (and I assume this is what you want to achieve) by setting the Qt::FramlessWindowHint flag.
          @
          int main(int argc, char *argv[])
          {
          QApplication a(argc, argv);

          QLabel label;
          
          label.setWindowFlags(Qt::FramelessWindowHint);
          label.setPixmap(QPixmap("logo.png"));
          label.show();
          
          return a.exec(&#41;;
          

          }
          @
          Brain to terminal. Not tested. Exemplary.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            p-himik
            wrote on last edited by
            #5

            As said dmcr, if you want framelesswindow just replace 8'th line with:
            @QLabel imageLabel( 0, Qt::FramelessWindowHint );@

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pratik041
              wrote on last edited by
              #6

              Thank you.........

              Pratik Agrawal

              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