Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Qt Stylesheets
Qt 6.11 is out! See what's new in the release blog

Qt Stylesheets

Scheduled Pinned Locked Moved Solved German
39 Posts 3 Posters 22.2k Views
  • 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.
  • G Galilio

    erste mal vielen vielen dank.
    Es funktioniert.
    Allerdings mit einen neben Effekt. Ich kann die Application nicht mehr mit der Maus bewegen.

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #7

    @Galilio said in Qt Stylesheets:

    Ich kann die Application nicht mehr mit der Maus bewegen.

    ja klar.
    Wie hast du dir vorgestellt das Fenster zu bewegen?

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    G 1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #8

      Du kannst die mouse event handler überschreiben, um das Fenster wieder beweglich zu machen.

      1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Galilio said in Qt Stylesheets:

        Ich kann die Application nicht mehr mit der Maus bewegen.

        ja klar.
        Wie hast du dir vorgestellt das Fenster zu bewegen?

        G Offline
        G Offline
        Galilio
        wrote on last edited by
        #9

        @raven-worx

        Ich dachte, dass ich das Fenster mit der Maus bewegen kann.

        raven-worxR 1 Reply Last reply
        0
        • G Galilio

          @raven-worx

          Ich dachte, dass ich das Fenster mit der Maus bewegen kann.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #10

          @Galilio
          ja, aber wie geanu?
          Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

          // in .h
          QPoint hotSpot;
          
          // in .cpp
          void MyWidget::mousePressEvent( QMouseEvent* event )
          {
               if( event->button() == Qt::LeftButton )
               {
                       hotSpot = this->mapFromGlobal(event->globalPos());
                       event->accept();
                       return;
               }
               BaseClass::mousePressEvent( event );
          }
          
          void MyWidget::mouseMoveEvent( QMouseEvent* event )
          {
                if( hotSpot.isValid() )
                {
                      this->move( event->globalPos() + hotSpot );
                      event->accept();
                      return;
                }
                BaseClass::mouseMoveEvent( event );
          }
          
          void MyWidget::mouseReleaseEvent( QMouseEvent* event )
          {
               if( event->button() == Qt::LeftButton )
               {
                       hotSpot = QPoint();
                       event->accept();
                       return;
                }
               BaseClass::mousePressEvent( event );
          }
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          ? G 2 Replies Last reply
          0
          • raven-worxR raven-worx

            @Galilio
            ja, aber wie geanu?
            Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

            // in .h
            QPoint hotSpot;
            
            // in .cpp
            void MyWidget::mousePressEvent( QMouseEvent* event )
            {
                 if( event->button() == Qt::LeftButton )
                 {
                         hotSpot = this->mapFromGlobal(event->globalPos());
                         event->accept();
                         return;
                 }
                 BaseClass::mousePressEvent( event );
            }
            
            void MyWidget::mouseMoveEvent( QMouseEvent* event )
            {
                  if( hotSpot.isValid() )
                  {
                        this->move( event->globalPos() + hotSpot );
                        event->accept();
                        return;
                  }
                  BaseClass::mouseMoveEvent( event );
            }
            
            void MyWidget::mouseReleaseEvent( QMouseEvent* event )
            {
                 if( event->button() == Qt::LeftButton )
                 {
                         hotSpot = QPoint();
                         event->accept();
                         return;
                  }
                 BaseClass::mousePressEvent( event );
            }
            
            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #11

            @raven-worx Hängt glaub ich auch vom Desktop-System ab: Unter KDE braucht man, um Fenster zu verschieben, ja nicht unbedingt mit der Maus an der window title bar herumzuziehen; da kann man auch Alt + <linke Maustaste gedrückt halten> direkt ins Fenster machen und dann verschieben.

            1 Reply Last reply
            0
            • raven-worxR raven-worx

              @Galilio
              ja, aber wie geanu?
              Da ja nun kein Fenster-Rahmen mehr da ist um das Fenster zu bewegen. Man kann es nun schon so implementieren, dass du das Fenster an einer beliebigen Position (auf dem Hintergrund) verschieben kannst:

              // in .h
              QPoint hotSpot;
              
              // in .cpp
              void MyWidget::mousePressEvent( QMouseEvent* event )
              {
                   if( event->button() == Qt::LeftButton )
                   {
                           hotSpot = this->mapFromGlobal(event->globalPos());
                           event->accept();
                           return;
                   }
                   BaseClass::mousePressEvent( event );
              }
              
              void MyWidget::mouseMoveEvent( QMouseEvent* event )
              {
                    if( hotSpot.isValid() )
                    {
                          this->move( event->globalPos() + hotSpot );
                          event->accept();
                          return;
                    }
                    BaseClass::mouseMoveEvent( event );
              }
              
              void MyWidget::mouseReleaseEvent( QMouseEvent* event )
              {
                   if( event->button() == Qt::LeftButton )
                   {
                           hotSpot = QPoint();
                           event->accept();
                           return;
                    }
                   BaseClass::mousePressEvent( event );
              }
              
              G Offline
              G Offline
              Galilio
              wrote on last edited by
              #12

              @raven-worx said in Qt Stylesheets:

              // in .h
              QPoint hotSpot;

              // in .cpp
              void MyWidget::mousePressEvent( QMouseEvent* event )
              {
              if( event->button() == Qt::LeftButton )
              {
              hotSpot = this->mapFromGlobal(event->globalPos());
              event->accept();
              return;
              }
              BaseClass::mousePressEvent( event );
              }

              void MyWidget::mouseMoveEvent( QMouseEvent* event )
              {
              if( hotSpot.isValid() )
              {
              this->move( event->globalPos() + hotSpot );
              event->accept();
              return;
              }
              BaseClass::mouseMoveEvent( event );
              }

              void MyWidget::mouseReleaseEvent( QMouseEvent* event )
              {
              if( event->button() == Qt::LeftButton )
              {
              hotSpot = QPoint();
              event->accept();
              return;
              }
              BaseClass::mousePressEvent( event );
              }

              vielen dank
              Es ist genau was ich brauche:
              Hier meine kleine Ergänzung:

              // in .h
              QPoint hotSpot;
              
              // in .cpp
              void MyWidget::mousePressEvent( QMouseEvent* event )
              {
                   if( event->button() == Qt::LeftButton )
                   {
                           hotSpot = this->mapFromGlobal(event->globalPos());
                           event->accept();
                           return;
                   }
              	if (event->button() == Qt::RightButton)
              	{
              		hotSpot = this->mapFromGlobal(event->globalPos());
              		event->accept();
              		return;
              	}
                   BaseClass::mousePressEvent( event );
              }
              
              void MyWidget::mouseMoveEvent( QMouseEvent* event )
              {
                  QPoint point = event->pos() - hotSpot;
              	if (point.manhattanLength()>0)
                          this->move( event->globalPos() - hotSpot );
                          event->accept();
                          return;
                    }
                    BaseClass::mouseMoveEvent( event );
              }
              
              void MyWidget::mouseReleaseEvent( QMouseEvent* event )
              {
                   if( event->button() == Qt::LeftButton )
                   {
                           hotSpot = QPoint();
                           event->accept();
                           return;
                    }
                   BaseClass::mousePressEvent( event );
              }
              

              sonst funktioniert alles
              nochmal danke

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Galilio
                wrote on last edited by
                #13

                Guten morgen Zusammen,

                eine Frage zu dem Thema.

                ich habe einen Dialog in MyApplication.
                In dieses Dialog möchte ich auch das gleiche Design wie MyApplication
                Dieses Dialog wird so gerufen:

                void MyApplication::showAboutApplication()
                {
                AboutDialog *dialog = new AboutDiaolog(this);
                dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                dialog->setAttribute(Qt::WA_TranslucentBackground);
                dialog->exec();
                delete dialog;
                
                }
                

                Das komisch daran ist, dass das Dialog abgeschnitten wird.
                was ist daran falsch?

                danke in voraus

                raven-worxR 1 Reply Last reply
                0
                • G Galilio

                  Guten morgen Zusammen,

                  eine Frage zu dem Thema.

                  ich habe einen Dialog in MyApplication.
                  In dieses Dialog möchte ich auch das gleiche Design wie MyApplication
                  Dieses Dialog wird so gerufen:

                  void MyApplication::showAboutApplication()
                  {
                  AboutDialog *dialog = new AboutDiaolog(this);
                  dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                  dialog->setAttribute(Qt::WA_TranslucentBackground);
                  dialog->exec();
                  delete dialog;
                  
                  }
                  

                  Das komisch daran ist, dass das Dialog abgeschnitten wird.
                  was ist daran falsch?

                  danke in voraus

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #14

                  @Galilio
                  ist ein Layout auf dem Dialog gesetzt? Wenn ja, dann:

                  void MyApplication::showAboutApplication()
                  {
                  AboutDialog *dialog = new AboutDiaolog(this);
                  dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                  dialog->setAttribute(Qt::WA_TranslucentBackground);
                  dialog->resize( dialog->sizeHint() );  // <<<<<<<<<<<<
                  dialog->exec();
                  delete dialog;
                  }
                  

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Galilio
                    wrote on last edited by
                    #15

                    Hallo,

                    es passiert nichts.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      Galilio
                      wrote on last edited by
                      #16

                      Mit passiert nichts meine ich: Dialog wird nicht mal gezeigt

                      raven-worxR 1 Reply Last reply
                      0
                      • G Galilio

                        Mit passiert nichts meine ich: Dialog wird nicht mal gezeigt

                        raven-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by
                        #17

                        @Galilio
                        du hast geschrieben

                        Das komisch daran ist, dass das Dialog abgeschnitten wird.

                        ???

                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                        If you have a question please use the forum so others can benefit from the solution in the future

                        G 1 Reply Last reply
                        0
                        • raven-worxR raven-worx

                          @Galilio
                          du hast geschrieben

                          Das komisch daran ist, dass das Dialog abgeschnitten wird.

                          ???

                          G Offline
                          G Offline
                          Galilio
                          wrote on last edited by
                          #18

                          @raven-worx

                          1. Ohne das:
                          dialog->resize(dialog->sizeHint());
                          

                          Dialog ist abgeschnitten.

                          1. Mit:
                          dialog->resize(dialog->sizeHint());
                          

                          wird nichts gezeigt

                          raven-worxR 1 Reply Last reply
                          0
                          • G Galilio

                            @raven-worx

                            1. Ohne das:
                            dialog->resize(dialog->sizeHint());
                            

                            Dialog ist abgeschnitten.

                            1. Mit:
                            dialog->resize(dialog->sizeHint());
                            

                            wird nichts gezeigt

                            raven-worxR Offline
                            raven-worxR Offline
                            raven-worx
                            Moderators
                            wrote on last edited by
                            #19

                            @Galilio
                            dann verwendest du kein Layout in dialog?

                            Mein Vorschlag funktioniert nur wenn du ein Layout verwendest (oder sizeHint() überladen hast). Ohne Layout musst du den Dialog selbst resizen bis es passt.

                            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                            If you have a question please use the forum so others can benefit from the solution in the future

                            G 1 Reply Last reply
                            0
                            • raven-worxR raven-worx

                              @Galilio
                              dann verwendest du kein Layout in dialog?

                              Mein Vorschlag funktioniert nur wenn du ein Layout verwendest (oder sizeHint() überladen hast). Ohne Layout musst du den Dialog selbst resizen bis es passt.

                              G Offline
                              G Offline
                              Galilio
                              wrote on last edited by
                              #20

                              @raven-worx

                              doch ich verwende einen Layout und zwar den Grid Layout.

                              raven-worxR 1 Reply Last reply
                              0
                              • G Galilio

                                @raven-worx

                                doch ich verwende einen Layout und zwar den Grid Layout.

                                raven-worxR Offline
                                raven-worxR Offline
                                raven-worx
                                Moderators
                                wrote on last edited by
                                #21

                                @Galilio
                                was gibt folgendes zurück?

                                qDebug() << dialog->layout();
                                

                                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                If you have a question please use the forum so others can benefit from the solution in the future

                                G 1 Reply Last reply
                                0
                                • raven-worxR raven-worx

                                  @Galilio
                                  was gibt folgendes zurück?

                                  qDebug() << dialog->layout();
                                  
                                  G Offline
                                  G Offline
                                  Galilio
                                  wrote on last edited by
                                  #22

                                  @raven-worx

                                  QGridLayout(0x142624d8, name = "gridLayout_2")

                                  raven-worxR 1 Reply Last reply
                                  0
                                  • G Galilio

                                    @raven-worx

                                    QGridLayout(0x142624d8, name = "gridLayout_2")

                                    raven-worxR Offline
                                    raven-worxR Offline
                                    raven-worx
                                    Moderators
                                    wrote on last edited by
                                    #23

                                    @Galilio
                                    hmm...strange.
                                    Dann dürfte irgendein widget in der Hierachie nicht sizeHint() implementiert haben, oder eine maximum size gesetzt sein? ... kA
                                    Bleibt wohl nur das "händische resizen".

                                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                    If you have a question please use the forum so others can benefit from the solution in the future

                                    G 1 Reply Last reply
                                    0
                                    • raven-worxR raven-worx

                                      @Galilio
                                      hmm...strange.
                                      Dann dürfte irgendein widget in der Hierachie nicht sizeHint() implementiert haben, oder eine maximum size gesetzt sein? ... kA
                                      Bleibt wohl nur das "händische resizen".

                                      G Offline
                                      G Offline
                                      Galilio
                                      wrote on last edited by
                                      #24

                                      @raven-worx
                                      jetzt wenn ich das anwende:

                                      	AboutDialog *dialog = new AboutDialog(this);
                                      	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                      	dialog->setAttribute(Qt::WA_TranslucentBackground);
                                      	dialog->resize(dialog->sizeHint());
                                      

                                      oder

                                      	AboutDialog *dialog = new AboutDialog(this);
                                      	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                      	dialog->setAttribute(Qt::WA_TranslucentBackground);
                                      

                                      --> Dialog wird gar nicht gezeigt
                                      Ich setze auch nirgend eine Minimum bzw. Maximum

                                      raven-worxR 1 Reply Last reply
                                      0
                                      • G Galilio

                                        @raven-worx
                                        jetzt wenn ich das anwende:

                                        	AboutDialog *dialog = new AboutDialog(this);
                                        	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                        	dialog->setAttribute(Qt::WA_TranslucentBackground);
                                        	dialog->resize(dialog->sizeHint());
                                        

                                        oder

                                        	AboutDialog *dialog = new AboutDialog(this);
                                        	dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
                                        	dialog->setAttribute(Qt::WA_TranslucentBackground);
                                        

                                        --> Dialog wird gar nicht gezeigt
                                        Ich setze auch nirgend eine Minimum bzw. Maximum

                                        raven-worxR Offline
                                        raven-worxR Offline
                                        raven-worx
                                        Moderators
                                        wrote on last edited by
                                        #25

                                        @Galilio said in Qt Stylesheets:

                                        dialog->resize(dialog->sizeHint());

                                        dialog->resize( QSize(x,y) ); //<< passende size
                                        

                                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                        If you have a question please use the forum so others can benefit from the solution in the future

                                        G 1 Reply Last reply
                                        0
                                        • raven-worxR raven-worx

                                          @Galilio said in Qt Stylesheets:

                                          dialog->resize(dialog->sizeHint());

                                          dialog->resize( QSize(x,y) ); //<< passende size
                                          
                                          G Offline
                                          G Offline
                                          Galilio
                                          wrote on last edited by
                                          #26

                                          @raven-worx
                                          Dialog wird trotzdem nicht gezeigt

                                          raven-worxR 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