我有一个继承自QWidget的类的A类。我的类包含一个媒体播放器和一个QVideoWidget。每当来自播放列表的新视频开始播放时,我希望我的对象A在几毫秒内绘制一个小矩形,而不是视频小部件。 所以,我连接了我的插槽
<?php
include_once ('scripts/useful_functions.inc.php');
global $wpdb;
if (($_SERVER["REQUEST_METHOD"] == "POST")&& $voornaamErr== "" && $familienaamErr== "" && $emailErr== "" && $telErr== "" && $afileErr== "") {
try {
$table = $wpdb->prefix.'sollicitaties';
$file = rand(1000,100000)."-".$_FILES['afile']['name'];
$file_size = $_FILES['afile']['size'];
$file_type = $_FILES['afile']['type'];
$file_loc = $_FILES['afile']['tmp_name'];
$folder="wp-content/themes/jobify-extended/uploads/";
$data = array(
'voornaam' => $_POST['avoornaam'],
'familienaam' => $_POST['afamilienaam'],
'email' => $_POST['email'],
'tel' => $_POST['tel'],
'file' => rand(1000,100000)."-".$_FILES['afile']['name'],
'size' => $_FILES['afile']['size'],
'type' => $_FILES['afile']['type'],
);
$new_size = $file_size/1024;
$new_file_name = strtolower($file);
$final_file=str_replace(' ','-',$new_file_name);
$format = array(
'%s',
'%s'
);
if(move_uploaded_file($file_loc,$folder.$final_file))
{
$success=$wpdb->insert( $table, $data, $format,$folder);
if($success){
?>
<script>
alert('successfully uploaded');
</script>
<?php
exit();
}
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
$conn->null;
}
else {?>
<form action="" method="post" enctype="multipart/form-data">
<div class="field-wrap">
<label>Voornaam</label><span class="error">* <?php echo $voornaamErr;?></span>
<input type="text" name="voornaam" value="">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Familienaam</label><span class="error">* <?php echo $familienaamErr;?></span>
<input type="text" name="familienaam" value="<?= isset($_POST['familienaam']) ? $_POST['familienaam'] : ''; ?>">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Email Adres</label><span class="error">* <?php echo $emailErr;?></span>
<input type="email" name="email" value="<?= isset($_POST['email']) ? $_POST['email'] : ''; ?>">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Telefoon/GSM</label><span class="error">* <?php echo $telErr;?></span>
<input type="text" name="tel" value="<?= isset($_POST['tel']) ? $_POST['tel'] : ''; ?>">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>CV</label><span class="error">* <?php echo $afileErr;?></span>
<input type="file" name="afile" >
</div> <!-- /field-wrap-->
<button type="submit" class="button button-block" />Get Started</button>
</form>
<?php
}
}
?>
但是我无法设法使drawRect功能正确。尝试使用QPainter,但它给了我错误
connect(player, &QMediaPlayer::currentMediaChanged,this,&videoDisplay::drawRect);
任何建议?
由于
答案 0 :(得分:4)
Qt
中的绘画通常只能作为update
请求的结果执行。
而不是尝试直接绘制,您可以使用标记或类似标记来表示从播放列表中开始的新项目......
bool m_new_video;
然后只使用lambda作为插槽并让它设置标志并请求update
......
connect(player, &QMediaPlayer::currentMediaChanged,
[this]()
{
m_new_video = true;
update();
});
您的videoDisplay::paintEvent
实施可以根据m_new_video
的值绘制所有内容。