Placing QPdfView-Widget in Qt-Designer
-
Hi,
i'm trying to figure out the usage of the QPdfView Widget, having a look at the PDF-Viewer Widget Example provided.
Interestingly in the Designer i can see that the QPdfView Widget has been placed in the main window, but i can't seem to find the widget itself in the Widget-Area from where i could drag and drop it to the form.
I tried to do this in an example project of myself, including the pdfwidget module in the project file (QT+= pdfwidgets), but again there's no QPdfView Widget to be selected in the general widget area.
I wonder if anyone can tell me how i'd manage to place a QPdfView Widget in my own custum mainwindow using the Qt-Designer.
Help much appreciated ...
-
Hi,
i'm trying to figure out the usage of the QPdfView Widget, having a look at the PDF-Viewer Widget Example provided.
Interestingly in the Designer i can see that the QPdfView Widget has been placed in the main window, but i can't seem to find the widget itself in the Widget-Area from where i could drag and drop it to the form.
I tried to do this in an example project of myself, including the pdfwidget module in the project file (QT+= pdfwidgets), but again there's no QPdfView Widget to be selected in the general widget area.
I wonder if anyone can tell me how i'd manage to place a QPdfView Widget in my own custum mainwindow using the Qt-Designer.
Help much appreciated ...
@wciibb said in Placing QPdfView-Widget in Qt-Designer:
I wonder if anyone can tell me how i'd manage to place a QPdfView Widget in my own custum mainwindow using the Qt-Designer.
Widget promotion is the keyword.
You place a plainQWidget
(easily selectable in QtDesigner) where yourQPdfWidget
should go.
Rightclick, promote to..., and then you select the header file of the widget which should replace the placeholder widget. -
-
Hello,
many thanks to Pl45m4 ...
This is the solution. I didn't had - until yet - the experience with custom widgets in the Qt-Designer using the Widget-Container in my form. But with the provided Link about using custom widgets and the hint to use the Classname of the QPdfView and providing its headerfile it worked like charm and i was able to put it onto my form and make it displaying a pdf within minutes.
Thanks a lot!
-
The QPdfView widget is part of the Qt PDF module and is not available by default in the Qt Designer’s widget box. However, you can still use it in your custom main window with a workaround. Here’s how you can do it:
Place a plain QWidget in your form where you want the QPdfView widget to be.
Right-click on the QWidget and select “Promote to…”.
In the “Promoted Widgets” dialog, you’ll need to enter the name of the class you want to promote to (QPdfView) and the header file (QPdfView).
Once you’ve added the promoted class, click “Add” and then “Promote”.
This will tell Qt Designer to treat the plain QWidget as a QPdfView widget at compile time. Remember to include the necessary headers and link against the PDF module in your project file. -
The QPdfView widget is part of the Qt PDF module and is not available by default in the Qt Designer’s widget box. However, you can still use it in your custom main window with a workaround. Here’s how you can do it:
Place a plain QWidget in your form where you want the QPdfView widget to be.
Right-click on the QWidget and select “Promote to…”.
In the “Promoted Widgets” dialog, you’ll need to enter the name of the class you want to promote to (QPdfView) and the header file (QPdfView).
Once you’ve added the promoted class, click “Add” and then “Promote”.
This will tell Qt Designer to treat the plain QWidget as a QPdfView widget at compile time. Remember to include the necessary headers and link against the PDF module in your project file.@beredis said in Placing QPdfView-Widget in Qt-Designer:
The QPdfView widget is part of the Qt PDF module and is not available by default in the Qt Designer’s widget box. However, you can still use it in your custom main window with a workaround. Here’s how you can do it:
Place a plain QWidget in your form where you want the QPdfView widget to be.
Right-click on the QWidget and select “Promote to…”.
In the “Promoted Widgets” dialog, you’ll need to enter the name of the class you want to promote to (QPdfView) and the header file (QPdfView).
Once you’ve added the promoted class, click “Add” and then “Promote”.
This will tell Qt Designer to treat the plain QWidget as a QPdfView widget at compile time. Remember to include the necessary headers and link against the PDF module in your project file.Do you think this was needed now?
This topic is solved and already contains a solution on how to promote a widget.