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. Load video (.mp4) and .css in Qt Help Assistant

Load video (.mp4) and .css in Qt Help Assistant

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.0k 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.
  • huy-congH Offline
    huy-congH Offline
    huy-cong
    wrote on last edited by
    #1

    Hi,
    I'm trying to load some dynamic elements to my application help menu using Qt Help Project File. I have no problem loading the .html files, but other files like .mp4, .png, and .css are not likely taken into account.
    So when I open my application, only a virgin version of my .html files appears (no images, no videos, and no fonts defined in .css, but the content is correct), Idk if I must do anything specific to load files (especially videos) with Qt (because it seems that's a bit tricky with Qt)
    Anyway, my Qt Help Project File looks like this, knowing that the paths are correct, if anyone have an idea please help me out.
    Thanks a lot guys!

    <?xml version="1.0" encoding="UTF-8"?>
    <QtHelpProject version="1.0">
        <namespace>myapp.qt.help.fr</namespace>
        <virtualFolder>help</virtualFolder>
    	<filterSection>
            <toc>
    			<section title="Page" >
    				<section title="Page 1" ref="page1.html"></section>
    				<section title="Page 2" ref="page2.html"></section>
    			</section>
            </toc>
    		<keywords>
    			<keyword name="Page 1" ref="page1.html"/>
    			<keyword name="Page 2" ref="page1.html"/>
    		</keywords>
            <files>
    			<file>media/*.png</file>
    			<file>media/*.jpg</file>
    			<file>media/*.mp4</file>
    			<file>style.css</file>
                <file>*.html</file>
            </files>
    	<filterSection>	
    </QtHelpProject>
    
    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      Yash001
      wrote on last edited by Yash001
      #2
      1. add the Resource file .qrc in QT Project.
        RESOURCES += gui.qrc

      2. add Prefix (/gui) and file (style.css)in gui.qrc with help of Editor.

      gui.qrc file text.

      <RCC>
               <qtresource prefix="/gui">
                        <file>style.css</file>
                </qtresource>
      </RCC>
      
      1. You can use this function. You can call Applystyle function whenever you want to load the .css style.
      void MainWindow::ApplyStyle() {
      #ifndef QT_NO_DEBUG
          QFile f(":/gui/style.css");
      
          if(!f.open(QIODevice::ReadOnly))
              return;
      
      	QString newStyleSheet = f.readAll();
      	
      #ifndef QT_NO_DEBUG
      	{
      		QRegExp imageSource("(:/GUI)");
      		QString localSource(".");
      		int offset = 0;
      
      		while (-1 != (offset = imageSource.indexIn(newStyleSheet, offset))) {
      			newStyleSheet.replace(offset, imageSource.cap(1).size(), localSource);
      			offset += localSource.size();
      		}
      	}
      #endif
      	// change the .css file value w.r.t. to screen resolution 
      	if((ratio <1.0) && (ratio > 0) ) {
      		QRegExp sizeRx("(\\d+)px");
      		int offset = 0;
      
      		while (-1 != (offset = sizeRx.indexIn(newStyleSheet, offset))) {
      			int val = sizeRx.cap(1).toInt();
      			int sizeOffset = sizeRx.cap(1).size();
      
      			if (val > 1) {
      				val *= ratio;
      
      				QString newSize = QString("%1").arg(val);
      
      				newStyleSheet.replace(offset, sizeRx.cap(1).size(), newSize);
      				sizeOffset = newSize.size();
      			}
      
      			offset += sizeOffset;
      		}
      	}
      
          qobject_cast<QApplication *>(QApplication::instance())->setStyleSheet(newStyleSheet);
      
          f.close();
      }
      
      1 Reply Last reply
      0
      • huy-congH Offline
        huy-congH Offline
        huy-cong
        wrote on last edited by huy-cong
        #3

        Hi Yash001,
        Thanks a lot for your answer, I think this is the way to load .css file to the whole application, right?

        What I wanted to do is to load elements to my help menu only, separated from the rest of the application (which I did with .qhp file above), the final goal is to load help menu with .qhc file & QHelpEngine class, like what is described here:
        http://doc.qt.io/qt-5/qthelp-framework.html
        http://doc.qt.io/qt-5/qthelpproject.html
        http://doc.qt.io/qt-5/qhelpengine.html

        The problem is the <file></file> tag doesn't seem to be properly loaded, since I cannot see any medias when the .html files are called, neither the .css format.

        Am I missing something at that point?

        1 Reply Last reply
        0
        • huy-congH Offline
          huy-congH Offline
          huy-cong
          wrote on last edited by
          #4

          Hi,
          I'm making a bit progression on my program.
          In fact, I realize that my .qhc file works great with Qt Assistant, which I try with this command:
          assistant -collectionFile helpmenu.qhc
          Every videos, images, css style, and fonts are properly loaded.

          However, in my application, when I loaded the same helpmenu.qhc with QHelpEngine using:
          QHelpEngine(const QString &collectionFile, QObject *parent = 0);
          Not everything was properly loaded (images yes, but no videos, and still no .css style), do I have to load it also on my .qrc file?
          Please, if someone have an idea, let me know.
          Thanks

          V 1 Reply Last reply
          1
          • huy-congH huy-cong

            Hi,
            I'm making a bit progression on my program.
            In fact, I realize that my .qhc file works great with Qt Assistant, which I try with this command:
            assistant -collectionFile helpmenu.qhc
            Every videos, images, css style, and fonts are properly loaded.

            However, in my application, when I loaded the same helpmenu.qhc with QHelpEngine using:
            QHelpEngine(const QString &collectionFile, QObject *parent = 0);
            Not everything was properly loaded (images yes, but no videos, and still no .css style), do I have to load it also on my .qrc file?
            Please, if someone have an idea, let me know.
            Thanks

            V Offline
            V Offline
            vanegas
            wrote on last edited by
            #5

            @huy-cong I am trying to load my mp4 video into qt assistant, but I just get the message "Your browser does not support HTML video. ".

            I am using Qt 5.13 and the html I am using to load the video is:

            <video width="400" controls>
            <source src="videos/mov_bbb.mp4" type="video/mp4">
            <source src="videos/mov_bbb.ogg" type="video/ogg">
            Your browser does not support HTML video.
            </video>

            Can you tell me how you embedded your video in your .html file?

            Thanks!

            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